@doccov/sdk 0.29.4 → 0.30.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.
@@ -258,7 +258,7 @@ declare function hasNonAssertionComments(code: string): boolean;
258
258
  */
259
259
  declare function detectExampleAssertionFailures(entry: SpecExport2, runtimeResults: Map<number, ExampleRunResult>): SpecDocDrift[];
260
260
  import { OpenPkg as OpenPkg2 } from "@openpkg-ts/spec";
261
- /** Directory for storing history snapshots */
261
+ /** Directory for storing history snapshots (relative to .doccov) */
262
262
  declare const HISTORY_DIR = ".doccov/history";
263
263
  /**
264
264
  * A historical coverage snapshot.
@@ -351,14 +351,18 @@ declare function computeSnapshot(spec: OpenPkg2, options?: {
351
351
  /**
352
352
  * Save a coverage snapshot to history.
353
353
  *
354
+ * Uses project root for .doccov location (walks up from cwd to find root).
355
+ *
354
356
  * @param snapshot - The snapshot to save
355
- * @param cwd - Working directory
357
+ * @param cwd - Working directory (will resolve to project root)
356
358
  */
357
359
  declare function saveSnapshot(snapshot: CoverageSnapshot, cwd: string): void;
358
360
  /**
359
361
  * Load all historical snapshots.
360
362
  *
361
- * @param cwd - Working directory
363
+ * Uses project root for .doccov location (walks up from cwd to find root).
364
+ *
365
+ * @param cwd - Working directory (will resolve to project root)
362
366
  * @returns Array of snapshots sorted by timestamp (most recent first)
363
367
  */
364
368
  declare function loadSnapshots(cwd: string): CoverageSnapshot[];
@@ -391,7 +395,9 @@ declare function formatDelta(delta: number): string;
391
395
  /**
392
396
  * Prune old snapshots to keep history manageable.
393
397
  *
394
- * @param cwd - Working directory
398
+ * Uses project root for .doccov location (walks up from cwd to find root).
399
+ *
400
+ * @param cwd - Working directory (will resolve to project root)
395
401
  * @param keepCount - Number of snapshots to keep (default: 100)
396
402
  * @returns Number of snapshots deleted
397
403
  */
@@ -36,7 +36,7 @@ import {
36
36
  renderSparkline,
37
37
  saveReport,
38
38
  saveSnapshot
39
- } from "../shared/chunk-0048g7g0.js";
39
+ } from "../shared/chunk-8jre4296.js";
40
40
  import"../shared/chunk-r4wa72ae.js";
41
41
  export {
42
42
  saveSnapshot,
package/dist/index.d.ts CHANGED
@@ -767,13 +767,17 @@ interface CacheContext {
767
767
  /**
768
768
  * Load cached spec from disk.
769
769
  *
770
- * @param cwd - Working directory
770
+ * Uses project root for cache location (walks up from cwd to find root).
771
+ *
772
+ * @param cwd - Working directory (will resolve to project root)
771
773
  * @returns Cached spec, or null if not found or invalid JSON
772
774
  */
773
775
  declare function loadSpecCache(cwd: string): SpecCache | null;
774
776
  /**
775
777
  * Save spec to cache.
776
778
  *
779
+ * Uses project root for cache location (walks up from cwd to find root).
780
+ *
777
781
  * @param spec - OpenPkg spec to cache
778
782
  * @param context - Cache context with file paths and config
779
783
  */
@@ -797,14 +801,18 @@ declare function validateSpecCache(cache: SpecCache, context: CacheContext): Cac
797
801
  /**
798
802
  * Clear the spec cache.
799
803
  *
800
- * @param cwd - Working directory
804
+ * Uses project root for cache location (walks up from cwd to find root).
805
+ *
806
+ * @param cwd - Working directory (will resolve to project root)
801
807
  * @returns True if cache was deleted, false if it didn't exist
802
808
  */
803
809
  declare function clearSpecCache(cwd: string): boolean;
804
810
  /**
805
811
  * Get cache file path for a given working directory.
806
812
  *
807
- * @param cwd - Working directory
813
+ * Uses project root for cache location (walks up from cwd to find root).
814
+ *
815
+ * @param cwd - Working directory (will resolve to project root)
808
816
  * @returns Absolute path to cache file
809
817
  */
810
818
  declare function getSpecCachePath(cwd: string): string;
@@ -2026,7 +2034,7 @@ interface DetectedSchemaEntry {
2026
2034
  vendor: string;
2027
2035
  }
2028
2036
  import { OpenPkg as OpenPkg6 } from "@openpkg-ts/spec";
2029
- /** Directory for storing history snapshots */
2037
+ /** Directory for storing history snapshots (relative to .doccov) */
2030
2038
  declare const HISTORY_DIR = ".doccov/history";
2031
2039
  /**
2032
2040
  * A historical coverage snapshot.
@@ -2119,14 +2127,18 @@ declare function computeSnapshot(spec: OpenPkg6, options?: {
2119
2127
  /**
2120
2128
  * Save a coverage snapshot to history.
2121
2129
  *
2130
+ * Uses project root for .doccov location (walks up from cwd to find root).
2131
+ *
2122
2132
  * @param snapshot - The snapshot to save
2123
- * @param cwd - Working directory
2133
+ * @param cwd - Working directory (will resolve to project root)
2124
2134
  */
2125
2135
  declare function saveSnapshot(snapshot: CoverageSnapshot, cwd: string): void;
2126
2136
  /**
2127
2137
  * Load all historical snapshots.
2128
2138
  *
2129
- * @param cwd - Working directory
2139
+ * Uses project root for .doccov location (walks up from cwd to find root).
2140
+ *
2141
+ * @param cwd - Working directory (will resolve to project root)
2130
2142
  * @returns Array of snapshots sorted by timestamp (most recent first)
2131
2143
  */
2132
2144
  declare function loadSnapshots(cwd: string): CoverageSnapshot[];
@@ -2159,7 +2171,9 @@ declare function formatDelta(delta: number): string;
2159
2171
  /**
2160
2172
  * Prune old snapshots to keep history manageable.
2161
2173
  *
2162
- * @param cwd - Working directory
2174
+ * Uses project root for .doccov location (walks up from cwd to find root).
2175
+ *
2176
+ * @param cwd - Working directory (will resolve to project root)
2163
2177
  * @param keepCount - Number of snapshots to keep (default: 100)
2164
2178
  * @returns Number of snapshots deleted
2165
2179
  */
@@ -2618,7 +2632,7 @@ interface SpecSummary {
2618
2632
  * ```
2619
2633
  */
2620
2634
  declare function extractSpecSummary(openpkg: OpenPkg8, doccov: DocCovSpec4): SpecSummary;
2621
- import { OpenPkg as OpenPkg_hlpylamjdn } from "@openpkg-ts/spec";
2635
+ import { OpenPkg as OpenPkg_clqpwbmpdv } from "@openpkg-ts/spec";
2622
2636
  /**
2623
2637
  * Build Plan types for AI-powered repository scanning.
2624
2638
  */
@@ -2715,7 +2729,7 @@ interface BuildPlanExecutionResult {
2715
2729
  /** Whether all required steps succeeded */
2716
2730
  success: boolean;
2717
2731
  /** Generated OpenPkg spec (if successful) */
2718
- spec?: OpenPkg_hlpylamjdn;
2732
+ spec?: OpenPkg_clqpwbmpdv;
2719
2733
  /** Results for each step */
2720
2734
  stepResults: BuildPlanStepResult[];
2721
2735
  /** Total execution time in milliseconds */
@@ -2723,4 +2737,28 @@ interface BuildPlanExecutionResult {
2723
2737
  /** Overall error message if failed */
2724
2738
  error?: string;
2725
2739
  }
2726
- export { validateSpecCache, validateExamples, typecheckExamples, typecheckExample, shouldValidate, serializeJSDoc, saveSpecCache, saveSnapshot, saveReport, safeParseJson, runExamplesWithPackage, runExamples, runExample, resolveTarget, resolveCompiledPath, renderSparkline, renderApiSurface, readPackageJson, pruneHistory, previewForgottenExportFixes, parseGitHubUrl2 as parseScanGitHubUrl, parseMarkdownFiles, parseMarkdownFile, parseListFlag, parseJSDocToPatch, parseGitHubUrl, parseExamplesFlag, parseAssertions, normalizeConfig, mergeFixes, mergeFilters, loadSpecCache, loadSnapshots, loadCachedReport, listWorkspacePackages, isStandardJSONSchema, isSchemaType, isFixableDrift, isExportFullyDocumented, isExecutableLang, installDependencies, hashString, hashFiles, hashFile, hasNonAssertionComments, hasDocsImpact, hasDocsForExport, groupFixesByFile, groupDriftsByCategory, getUndocumentedExports, getTrend, getSupportedLibraries, getSpecCachePath, getRunCommand, getReportPath, getRegisteredAdapters, getPrimaryBuildScript, getInstallCommand, getExtendedTrend, getExportScore, getExportMissing, getExportDrift, getExportAnalysis, getDriftSummary, getDocumentedExports, getDocsImpactSummary, getDiffReportPath, generateReportFromDocCov, generateReport, generateForgottenExportFixes, generateFixesForExport, generateFix, formatPackageList, formatDriftSummaryLine, formatDelta, findRemovedReferences, findPackageByName, findJSDocLocation, findExportReferences, findDeprecatedReferences, findAdapter, fetchSpecFromGitHub, fetchSpec, fetchGitHubContext, extractStandardSchemasFromProject, extractStandardSchemas, extractSpecSummary, extractSchemaType, extractSchemaOutputType, extractPackageSpec, extractImports, extractFunctionCalls, ensureSpecCoverage, docCovConfigSchema, diffSpecWithDocs, diffHashes, detectRuntimeSchemas, detectPackageManager, detectMonorepo, detectExampleRuntimeErrors, detectExampleAssertionFailures, detectEntryPoint, detectBuildInfo, defineConfig, createSourceFile, createNodeCommandRunner, computeSnapshot, computeHealth, computeExportDrift, computeDrift, clearSpecCache, categorizeDrifts, categorizeDrift, calculateAggregateCoverage, buildRawUrl, buildExportRegistry, buildDocCovSpec, buildDisplayUrl, buildCloneUrl, blockReferencesExport, applyPatchToJSDoc, applyForgottenExportFixes, applyEdits, analyzeProject2 as analyzeProject, analyzeFile, analyzeDocsImpact, analyze, WorkspacePackage, WorkspaceConfig, VALIDATION_INFO, TypecheckValidationResult, TypecheckResult, TypecheckOptions, SummaryDriftIssue, StandardSchemaExtractionResult, StandardSchemaExtractionOutput, StandardJSONSchemaV1, SpecSummary, SpecDocDrift, SpecDiffWithDocs, SpecCacheConfig, SpecCache, SchemaExtractionResult, SchemaExtractionMode, SchemaDetectionResult, SchemaDetectionContext, SchemaAdapter, SandboxFileSystem, SPEC_CACHE_FILE, RuntimeDrift, RunValidationResult, RunExamplesWithPackageResult, RunExamplesWithPackageOptions, RunExampleOptions, ResolvedTarget, ResolvedFilters, ResolveTargetOptions, ReleaseTag, 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, HealthInput, HISTORY_DIR, GitHubRepoMetadata, GitHubProjectContext, GenerateForgottenExportFixesOptions, ForgottenExportResult, ForgottenExportFix, FixType, FixSuggestion, FilterSource, FilterOptions, FileSystem, FetchGitHubContextOptions, ExtractStandardSchemasOptions, ExtendedTrendAnalysis, ExportReference, ExportDriftResult, ExportCoverageData, ExampleValidationTypeError, ExampleValidationResult, ExampleValidationOptions, ExampleValidationMode, ExampleValidation, ExampleTypeError, ExampleRunResult, EntryPointSource, EntryPointInfo, DriftType, DriftSummary, DriftResult, DriftReportSummary, DriftReport, DriftCategory, DocsImpactResult, DocsImpactReference, DocsImpact, DocsConfig, DocsChangeType, DocCovReport, DocCovOptions, DocCovConfigInput, DocCovConfig, DocCov, DiffWithDocsOptions, Diagnostic, DetectedSchemaEntry, DetectedPackageManager, DRIFT_CATEGORY_LABELS, DRIFT_CATEGORY_DESCRIPTIONS, DRIFT_CATEGORIES, 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, BuildDocCovOptions, ApplyForgottenExportResult, ApplyEditsResult, AnalyzeProjectOptions, AnalyzeOptions, AnalysisResult, ALL_VALIDATIONS };
2740
+ /**
2741
+ * Find the project root by walking up from the given directory.
2742
+ *
2743
+ * Looks for:
2744
+ * 1. .git directory
2745
+ * 2. pnpm-workspace.yaml
2746
+ * 3. package.json with "workspaces" field
2747
+ * 4. Other monorepo markers (lerna.json, nx.json, rush.json)
2748
+ *
2749
+ * Falls back to the original directory if no root is found.
2750
+ *
2751
+ * @param startDir - Directory to start searching from
2752
+ * @returns Absolute path to the project root
2753
+ */
2754
+ declare function findProjectRoot(startDir: string): string;
2755
+ /**
2756
+ * Get the .doccov cache directory for a project.
2757
+ *
2758
+ * Always uses the project root, not the package directory.
2759
+ *
2760
+ * @param cwd - Current working directory or package directory
2761
+ * @returns Absolute path to the .doccov directory
2762
+ */
2763
+ declare function getDoccovDir(cwd: string): string;
2764
+ export { validateSpecCache, validateExamples, typecheckExamples, typecheckExample, shouldValidate, serializeJSDoc, saveSpecCache, saveSnapshot, saveReport, safeParseJson, runExamplesWithPackage, runExamples, runExample, resolveTarget, resolveCompiledPath, renderSparkline, renderApiSurface, readPackageJson, pruneHistory, previewForgottenExportFixes, parseGitHubUrl2 as parseScanGitHubUrl, parseMarkdownFiles, parseMarkdownFile, parseListFlag, parseJSDocToPatch, parseGitHubUrl, parseExamplesFlag, parseAssertions, normalizeConfig, mergeFixes, mergeFilters, loadSpecCache, loadSnapshots, loadCachedReport, listWorkspacePackages, isStandardJSONSchema, isSchemaType, isFixableDrift, isExportFullyDocumented, isExecutableLang, installDependencies, hashString, hashFiles, hashFile, hasNonAssertionComments, hasDocsImpact, hasDocsForExport, groupFixesByFile, groupDriftsByCategory, getUndocumentedExports, getTrend, getSupportedLibraries, getSpecCachePath, getRunCommand, getReportPath, getRegisteredAdapters, getPrimaryBuildScript, getInstallCommand, getExtendedTrend, getExportScore, getExportMissing, getExportDrift, getExportAnalysis, getDriftSummary, getDocumentedExports, getDocsImpactSummary, getDoccovDir, getDiffReportPath, generateReportFromDocCov, generateReport, generateForgottenExportFixes, generateFixesForExport, generateFix, formatPackageList, formatDriftSummaryLine, formatDelta, findRemovedReferences, findProjectRoot, findPackageByName, findJSDocLocation, findExportReferences, findDeprecatedReferences, findAdapter, fetchSpecFromGitHub, fetchSpec, fetchGitHubContext, extractStandardSchemasFromProject, extractStandardSchemas, extractSpecSummary, extractSchemaType, extractSchemaOutputType, extractPackageSpec, extractImports, extractFunctionCalls, ensureSpecCoverage, docCovConfigSchema, diffSpecWithDocs, diffHashes, detectRuntimeSchemas, detectPackageManager, detectMonorepo, detectExampleRuntimeErrors, detectExampleAssertionFailures, detectEntryPoint, detectBuildInfo, defineConfig, createSourceFile, createNodeCommandRunner, computeSnapshot, computeHealth, computeExportDrift, computeDrift, clearSpecCache, categorizeDrifts, categorizeDrift, calculateAggregateCoverage, buildRawUrl, buildExportRegistry, buildDocCovSpec, buildDisplayUrl, buildCloneUrl, blockReferencesExport, applyPatchToJSDoc, applyForgottenExportFixes, applyEdits, analyzeProject2 as analyzeProject, analyzeFile, analyzeDocsImpact, analyze, WorkspacePackage, WorkspaceConfig, VALIDATION_INFO, TypecheckValidationResult, TypecheckResult, TypecheckOptions, SummaryDriftIssue, StandardSchemaExtractionResult, StandardSchemaExtractionOutput, StandardJSONSchemaV1, SpecSummary, SpecDocDrift, SpecDiffWithDocs, SpecCacheConfig, SpecCache, SchemaExtractionResult, SchemaExtractionMode, SchemaDetectionResult, SchemaDetectionContext, SchemaAdapter, SandboxFileSystem, SPEC_CACHE_FILE, RuntimeDrift, RunValidationResult, RunExamplesWithPackageResult, RunExamplesWithPackageOptions, RunExampleOptions, ResolvedTarget, ResolvedFilters, ResolveTargetOptions, ReleaseTag, 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, HealthInput, HISTORY_DIR, GitHubRepoMetadata, GitHubProjectContext, GenerateForgottenExportFixesOptions, ForgottenExportResult, ForgottenExportFix, FixType, FixSuggestion, FilterSource, FilterOptions, FileSystem, FetchGitHubContextOptions, ExtractStandardSchemasOptions, ExtendedTrendAnalysis, ExportReference, ExportDriftResult, ExportCoverageData, ExampleValidationTypeError, ExampleValidationResult, ExampleValidationOptions, ExampleValidationMode, ExampleValidation, ExampleTypeError, ExampleRunResult, EntryPointSource, EntryPointInfo, DriftType, DriftSummary, DriftResult, DriftReportSummary, DriftReport, DriftCategory, DocsImpactResult, DocsImpactReference, DocsImpact, DocsConfig, DocsChangeType, DocCovReport, DocCovOptions, DocCovConfigInput, DocCovConfig, DocCov, DiffWithDocsOptions, Diagnostic, DetectedSchemaEntry, DetectedPackageManager, DRIFT_CATEGORY_LABELS, DRIFT_CATEGORY_DESCRIPTIONS, DRIFT_CATEGORIES, 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, BuildDocCovOptions, ApplyForgottenExportResult, ApplyEditsResult, AnalyzeProjectOptions, AnalyzeOptions, AnalysisResult, ALL_VALIDATIONS };
package/dist/index.js CHANGED
@@ -26,6 +26,7 @@ import {
26
26
  extractStandardSchemasFromProject,
27
27
  findAdapter,
28
28
  findJSDocLocation,
29
+ findProjectRoot,
29
30
  formatDelta,
30
31
  formatDriftSummaryLine,
31
32
  generateFix,
@@ -33,6 +34,7 @@ import {
33
34
  generateForgottenExportFixes,
34
35
  generateReport,
35
36
  generateReportFromDocCov,
37
+ getDoccovDir,
36
38
  getDriftSummary,
37
39
  getExportAnalysis,
38
40
  getExportDrift,
@@ -64,7 +66,7 @@ import {
64
66
  saveSnapshot,
65
67
  serializeJSDoc,
66
68
  ts
67
- } from "./shared/chunk-0048g7g0.js";
69
+ } from "./shared/chunk-8jre4296.js";
68
70
  import {
69
71
  mergeFilters,
70
72
  parseListFlag
@@ -319,7 +321,7 @@ var CACHE_VERSION = "1.3.0";
319
321
  var SPEC_CACHE_FILE = ".doccov/cache/spec.cache.json";
320
322
  function loadSpecCache(cwd) {
321
323
  try {
322
- const cachePath = path5.resolve(cwd, SPEC_CACHE_FILE);
324
+ const cachePath = path5.join(getDoccovDir(cwd), "cache", "spec.cache.json");
323
325
  if (!fs4.existsSync(cachePath)) {
324
326
  return null;
325
327
  }
@@ -355,7 +357,7 @@ function saveSpecCache(spec, context) {
355
357
  specDiagnostics,
356
358
  forgottenExports
357
359
  };
358
- const cachePath = path5.resolve(cwd, SPEC_CACHE_FILE);
360
+ const cachePath = path5.join(getDoccovDir(cwd), "cache", "spec.cache.json");
359
361
  const dir = path5.dirname(cachePath);
360
362
  if (!fs4.existsSync(dir)) {
361
363
  fs4.mkdirSync(dir, { recursive: true });
@@ -390,7 +392,7 @@ function validateSpecCache(cache, context) {
390
392
  return { valid: true };
391
393
  }
392
394
  function clearSpecCache(cwd) {
393
- const cachePath = path5.resolve(cwd, SPEC_CACHE_FILE);
395
+ const cachePath = path5.join(getDoccovDir(cwd), "cache", "spec.cache.json");
394
396
  if (fs4.existsSync(cachePath)) {
395
397
  fs4.unlinkSync(cachePath);
396
398
  return true;
@@ -398,7 +400,7 @@ function clearSpecCache(cwd) {
398
400
  return false;
399
401
  }
400
402
  function getSpecCachePath(cwd) {
401
- return path5.resolve(cwd, SPEC_CACHE_FILE);
403
+ return path5.join(getDoccovDir(cwd), "cache", "spec.cache.json");
402
404
  }
403
405
  // src/extractor.ts
404
406
  import * as path6 from "node:path";
@@ -15420,7 +15422,7 @@ async function runExample(code, options = {}) {
15420
15422
  try {
15421
15423
  fs8.writeFileSync(tmpFile, cleanCode, "utf-8");
15422
15424
  const startTime = Date.now();
15423
- return await new Promise((resolve5) => {
15425
+ return await new Promise((resolve4) => {
15424
15426
  let stdout = "";
15425
15427
  let stderr = "";
15426
15428
  let killed = false;
@@ -15443,7 +15445,7 @@ async function runExample(code, options = {}) {
15443
15445
  clearTimeout(timeoutId);
15444
15446
  const duration3 = Date.now() - startTime;
15445
15447
  if (killed) {
15446
- resolve5({
15448
+ resolve4({
15447
15449
  success: false,
15448
15450
  stdout,
15449
15451
  stderr: stderr || `Example timed out after ${timeout}ms`,
@@ -15451,7 +15453,7 @@ async function runExample(code, options = {}) {
15451
15453
  duration: duration3
15452
15454
  });
15453
15455
  } else {
15454
- resolve5({
15456
+ resolve4({
15455
15457
  success: exitCode === 0,
15456
15458
  stdout,
15457
15459
  stderr,
@@ -15462,7 +15464,7 @@ async function runExample(code, options = {}) {
15462
15464
  });
15463
15465
  proc.on("error", (error48) => {
15464
15466
  clearTimeout(timeoutId);
15465
- resolve5({
15467
+ resolve4({
15466
15468
  success: false,
15467
15469
  stdout,
15468
15470
  stderr: error48.message,
@@ -15513,7 +15515,7 @@ function getInstallCommand2(pm, packagePath) {
15513
15515
  }
15514
15516
  }
15515
15517
  async function runCommand(cmd, args, options) {
15516
- return new Promise((resolve5) => {
15518
+ return new Promise((resolve4) => {
15517
15519
  let stdout = "";
15518
15520
  let stderr = "";
15519
15521
  let killed = false;
@@ -15534,14 +15536,14 @@ async function runCommand(cmd, args, options) {
15534
15536
  proc.on("close", (exitCode) => {
15535
15537
  clearTimeout(timeoutId);
15536
15538
  if (killed) {
15537
- resolve5({
15539
+ resolve4({
15538
15540
  success: false,
15539
15541
  stdout,
15540
15542
  stderr: stderr || `Command timed out after ${options.timeout}ms`,
15541
15543
  exitCode: exitCode ?? 1
15542
15544
  });
15543
15545
  } else {
15544
- resolve5({
15546
+ resolve4({
15545
15547
  success: exitCode === 0,
15546
15548
  stdout,
15547
15549
  stderr,
@@ -15551,7 +15553,7 @@ async function runCommand(cmd, args, options) {
15551
15553
  });
15552
15554
  proc.on("error", (error48) => {
15553
15555
  clearTimeout(timeoutId);
15554
- resolve5({
15556
+ resolve4({
15555
15557
  success: false,
15556
15558
  stdout,
15557
15559
  stderr: error48.message,
@@ -17110,6 +17112,7 @@ export {
17110
17112
  getDriftSummary,
17111
17113
  getDocumentedExports,
17112
17114
  getDocsImpactSummary,
17115
+ getDoccovDir,
17113
17116
  getDiffReportPath,
17114
17117
  generateReportFromDocCov,
17115
17118
  generateReport,
@@ -17120,6 +17123,7 @@ export {
17120
17123
  formatDriftSummaryLine,
17121
17124
  formatDelta,
17122
17125
  findRemovedReferences,
17126
+ findProjectRoot,
17123
17127
  findPackageByName,
17124
17128
  findJSDocLocation,
17125
17129
  findExportReferences,
@@ -2863,10 +2863,52 @@ async function detectRuntimeSchemas(context) {
2863
2863
  };
2864
2864
  }
2865
2865
 
2866
- // src/analysis/history.ts
2866
+ // src/utils/project-root.ts
2867
2867
  import * as fs4 from "node:fs";
2868
2868
  import * as path4 from "node:path";
2869
+ var PROJECT_ROOT_MARKERS = [
2870
+ ".git",
2871
+ "pnpm-workspace.yaml",
2872
+ "pnpm-workspace.yml",
2873
+ "lerna.json",
2874
+ "nx.json",
2875
+ "rush.json"
2876
+ ];
2877
+ function findProjectRoot(startDir) {
2878
+ let dir = path4.resolve(startDir);
2879
+ const root = path4.parse(dir).root;
2880
+ while (dir !== root) {
2881
+ for (const marker of PROJECT_ROOT_MARKERS) {
2882
+ const markerPath = path4.join(dir, marker);
2883
+ if (fs4.existsSync(markerPath)) {
2884
+ return dir;
2885
+ }
2886
+ }
2887
+ const pkgPath = path4.join(dir, "package.json");
2888
+ if (fs4.existsSync(pkgPath)) {
2889
+ try {
2890
+ const pkg = JSON.parse(fs4.readFileSync(pkgPath, "utf-8"));
2891
+ if (pkg.workspaces) {
2892
+ return dir;
2893
+ }
2894
+ } catch {}
2895
+ }
2896
+ dir = path4.dirname(dir);
2897
+ }
2898
+ return path4.resolve(startDir);
2899
+ }
2900
+ function getDoccovDir(cwd) {
2901
+ const projectRoot = findProjectRoot(cwd);
2902
+ return path4.join(projectRoot, ".doccov");
2903
+ }
2904
+
2905
+ // src/analysis/history.ts
2906
+ import * as fs5 from "node:fs";
2907
+ import * as path5 from "node:path";
2869
2908
  var HISTORY_DIR = ".doccov/history";
2909
+ function getHistoryDir(cwd) {
2910
+ return path5.join(getDoccovDir(cwd), "history");
2911
+ }
2870
2912
  var RETENTION_DAYS = 90;
2871
2913
  function getSnapshotFilename(timestamp) {
2872
2914
  const pad = (n) => n.toString().padStart(2, "0");
@@ -2899,24 +2941,24 @@ function computeSnapshot(spec, options) {
2899
2941
  };
2900
2942
  }
2901
2943
  function saveSnapshot(snapshot, cwd) {
2902
- const historyDir = path4.resolve(cwd, HISTORY_DIR);
2903
- if (!fs4.existsSync(historyDir)) {
2904
- fs4.mkdirSync(historyDir, { recursive: true });
2944
+ const historyDir = getHistoryDir(cwd);
2945
+ if (!fs5.existsSync(historyDir)) {
2946
+ fs5.mkdirSync(historyDir, { recursive: true });
2905
2947
  }
2906
2948
  const filename = getSnapshotFilename(new Date(snapshot.timestamp));
2907
- const filepath = path4.join(historyDir, filename);
2908
- fs4.writeFileSync(filepath, JSON.stringify(snapshot, null, 2));
2949
+ const filepath = path5.join(historyDir, filename);
2950
+ fs5.writeFileSync(filepath, JSON.stringify(snapshot, null, 2));
2909
2951
  }
2910
2952
  function loadSnapshots(cwd) {
2911
- const historyDir = path4.resolve(cwd, HISTORY_DIR);
2912
- if (!fs4.existsSync(historyDir)) {
2953
+ const historyDir = getHistoryDir(cwd);
2954
+ if (!fs5.existsSync(historyDir)) {
2913
2955
  return [];
2914
2956
  }
2915
- const files = fs4.readdirSync(historyDir).filter((f) => f.endsWith(".json")).sort().reverse();
2957
+ const files = fs5.readdirSync(historyDir).filter((f) => f.endsWith(".json")).sort().reverse();
2916
2958
  const snapshots = [];
2917
2959
  for (const file of files) {
2918
2960
  try {
2919
- const content = fs4.readFileSync(path4.join(historyDir, file), "utf-8");
2961
+ const content = fs5.readFileSync(path5.join(historyDir, file), "utf-8");
2920
2962
  snapshots.push(JSON.parse(content));
2921
2963
  } catch {}
2922
2964
  }
@@ -2956,15 +2998,15 @@ function formatDelta(delta) {
2956
2998
  return "→0%";
2957
2999
  }
2958
3000
  function pruneHistory(cwd, keepCount = 100) {
2959
- const historyDir = path4.resolve(cwd, HISTORY_DIR);
2960
- if (!fs4.existsSync(historyDir)) {
3001
+ const historyDir = getHistoryDir(cwd);
3002
+ if (!fs5.existsSync(historyDir)) {
2961
3003
  return 0;
2962
3004
  }
2963
- const files = fs4.readdirSync(historyDir).filter((f) => f.endsWith(".json")).sort().reverse();
3005
+ const files = fs5.readdirSync(historyDir).filter((f) => f.endsWith(".json")).sort().reverse();
2964
3006
  const toDelete = files.slice(keepCount);
2965
3007
  for (const file of toDelete) {
2966
3008
  try {
2967
- fs4.unlinkSync(path4.join(historyDir, file));
3009
+ fs5.unlinkSync(path5.join(historyDir, file));
2968
3010
  } catch {}
2969
3011
  }
2970
3012
  return toDelete.length;
@@ -3060,4 +3102,4 @@ function getExtendedTrend(spec, cwd, options) {
3060
3102
  };
3061
3103
  }
3062
3104
 
3063
- export { isFixableDrift, generateFix, generateFixesForExport, mergeFixes, categorizeDrifts, generateForgottenExportFixes, groupFixesByFile, applyForgottenExportFixes, previewForgottenExportFixes, ts, parseJSDocToPatch, applyPatchToJSDoc, serializeJSDoc, findJSDocLocation, applyEdits, createSourceFile, isBuiltInIdentifier, detectExampleRuntimeErrors, parseAssertions, hasNonAssertionComments, detectExampleAssertionFailures, buildExportRegistry, computeDrift, computeExportDrift, computeHealth, buildDocCovSpec, DRIFT_CATEGORIES2 as DRIFT_CATEGORIES, DRIFT_CATEGORY_LABELS, DRIFT_CATEGORY_DESCRIPTIONS, categorizeDrift, groupDriftsByCategory, getDriftSummary, formatDriftSummaryLine, calculateAggregateCoverage, ensureSpecCoverage, getExportAnalysis, getExportScore, getExportDrift, getExportMissing, isExportFullyDocumented, generateReport, generateReportFromDocCov, loadCachedReport, saveReport, isCachedReportValid, renderApiSurface, extractSchemaOutputType, getRegisteredAdapters, getSupportedLibraries, extractSchemaType, extractStandardSchemas, extractStandardSchemasFromProject, findAdapter, isSchemaType, isStandardJSONSchema, resolveCompiledPath, detectRuntimeSchemas, HISTORY_DIR, computeSnapshot, saveSnapshot, loadSnapshots, getTrend, renderSparkline, formatDelta, pruneHistory, loadSnapshotsForDays, generateWeeklySummaries, getExtendedTrend };
3105
+ export { isFixableDrift, generateFix, generateFixesForExport, mergeFixes, categorizeDrifts, generateForgottenExportFixes, groupFixesByFile, applyForgottenExportFixes, previewForgottenExportFixes, ts, parseJSDocToPatch, applyPatchToJSDoc, serializeJSDoc, findJSDocLocation, applyEdits, createSourceFile, isBuiltInIdentifier, detectExampleRuntimeErrors, parseAssertions, hasNonAssertionComments, detectExampleAssertionFailures, buildExportRegistry, computeDrift, computeExportDrift, computeHealth, buildDocCovSpec, DRIFT_CATEGORIES2 as DRIFT_CATEGORIES, DRIFT_CATEGORY_LABELS, DRIFT_CATEGORY_DESCRIPTIONS, categorizeDrift, groupDriftsByCategory, getDriftSummary, formatDriftSummaryLine, calculateAggregateCoverage, ensureSpecCoverage, getExportAnalysis, getExportScore, getExportDrift, getExportMissing, isExportFullyDocumented, generateReport, generateReportFromDocCov, loadCachedReport, saveReport, isCachedReportValid, renderApiSurface, extractSchemaOutputType, getRegisteredAdapters, getSupportedLibraries, extractSchemaType, extractStandardSchemas, extractStandardSchemasFromProject, findAdapter, isSchemaType, isStandardJSONSchema, resolveCompiledPath, detectRuntimeSchemas, findProjectRoot, getDoccovDir, HISTORY_DIR, computeSnapshot, saveSnapshot, loadSnapshots, getTrend, renderSparkline, formatDelta, pruneHistory, loadSnapshotsForDays, generateWeeklySummaries, getExtendedTrend };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@doccov/sdk",
3
- "version": "0.29.4",
3
+ "version": "0.30.0",
4
4
  "description": "DocCov SDK - Documentation coverage and drift detection for TypeScript",
5
5
  "keywords": [
6
6
  "typescript",