export type DocType = 'integration' | 'library'; export type AgentType = 'codex' | 'claude' | 'cursor'; export type DocResolutionStatus = 'resolved' | 'partially_resolved' | 'unresolved' | 'skipped'; export type FetchExtractor = 'static-html' | 'browser-rendered'; export type PackageTriageAction = 'direct' | 'map' | 'skip'; export type DocsSourceType = 'cache' | 'curated' | 'metadata' | 'ecosystem' | 'llms' | 'convention' | 'search' | 'override'; export type ResolutionConfidenceBand = 'high' | 'medium' | 'low'; export type ResolutionCacheStatus = 'miss' | 'fresh' | 'stale' | 'expired'; export interface PackageTriageResult { packageName: string; action: PackageTriageAction; canonicalPackage: string; mapTo?: string; ecosystem?: string; confidence: number; reason?: string; reasons: string[]; } export interface RegistryEntry { canonical: string; type: DocType; official: boolean; packageNames?: string[]; keywords?: string[]; docsBaseUrl: string; versionStrategy: 'latest_stable' | 'package_version_or_latest' | 'explicit_or_latest'; normalizationAdapter?: 'generic' | 'stripe-api' | 'google-ads-api' | 'meta-marketing-api'; docsPathPrefixes?: string[]; seedPaths?: string[]; maxPages?: number; maxDepth?: number; localPath: string; ttlHours?: number; ecosystem?: string; confidence?: number; notes?: string; llmsTxtUrl?: string; topicUrls?: Record; } export interface DocsSourceCandidate { packageName: string; canonicalPackage: string; type: DocType; sourceType: DocsSourceType; url: string; confidence: number; official: boolean; ecosystem?: string; llmsTxtUrl?: string; topicUrls?: Record; reasons: string[]; notes?: string; metadata?: Record; } export interface DocsSourceVerificationResult { url: string; accepted: boolean; confidence: number; reasons: string[]; canonicalUrl?: string; title?: string; description?: string; contentType?: string; wordCount?: number; docsSignals?: string[]; extractedHeadings?: string[]; } export interface DocsSourceResolutionResult { packageName: string; requestedName: string; canonicalPackage: string; triage: PackageTriageResult; status: DocResolutionStatus; type: DocType; confidenceBand: ResolutionConfidenceBand; cacheStatus: ResolutionCacheStatus; cacheAgeDays?: number; source?: DocsSourceCandidate; verification?: DocsSourceVerificationResult; candidates: DocsSourceCandidate[]; compareSources?: DocsSourceCandidate[]; reasons: string[]; } export interface CachedResolvedSource { packageName: string; canonicalPackage: string; docsUrl: string; sourceType: DocsSourceType; confidence: number; verifiedAt: string; llmsTxtUrl?: string; ecosystem?: string; type: DocType; notes?: string; rationale: string[]; } export interface DocsReadPage { url: string; title: string; content: string; summary: string; } export interface DocsReadResult { packageName?: string; canonicalPackage?: string; sourceUrl: string; topic?: string; pages: DocsReadPage[]; verification?: DocsSourceVerificationResult; cached: boolean; } export interface RelatedLocalFileHint { path: string; matchedTokens: string[]; reason: string; } export interface TaskTopicCandidate { topic: string; confidence: number; reasons: string[]; } export interface ResolvedTaskDoc { packageName: string; canonicalPackage: string; confidence: number; topic?: string; matchedFrom: string[]; relatedLocalFiles: string[]; relatedLocalFileHints: RelatedLocalFileHint[]; resolution: DocsSourceResolutionResult; read: DocsReadResult; implementationNotes: string[]; } export interface RepoProfile { rootDir?: string; frameworks: string[]; packages: string[]; sourceFiles: string[]; generatedAt: string; } export interface ResolveTaskDocsInput { taskText: string; rootDir?: string; filePaths?: string[]; } export interface LookupDocsInput extends ResolveTaskDocsInput { packageHint?: string; } export interface ResolveTaskDocsResult { taskText: string; repoProfile?: RepoProfile; detectedPackages: Array<{ name: string; confidence: number; matchedFrom: string[]; }>; topics: TaskTopicCandidate[]; docs: ResolvedTaskDoc[]; summary: string; followUpSuggestions: string[]; warnings: string[]; } export interface TaskDocsBrief { taskText: string; repoProfile?: RepoProfile; topics: string[]; packages: Array<{ packageName: string; canonicalPackage: string; topic?: string; sourceUrl: string; sourceType?: DocsSourceType; sourceReason?: string; confidence: number; relatedLocalFiles: string[]; relatedLocalFileHints?: RelatedLocalFileHint[]; resolutionStatus?: DocResolutionStatus; confidenceBand?: ResolutionConfidenceBand; compareSourceUrls?: string[]; alternateSources?: Array<{ url: string; sourceType: DocsSourceType; confidence: number; }>; }>; summary: string; implementationChecklist: string[]; warnings: string[]; cached: boolean; generatedAt: string; } export interface LookupDocsResult { question: string; packageHint?: string; answer: string; selectedPackage?: { packageName: string; canonicalPackage: string; topic?: string; sourceUrl: string; sourceType?: DocsSourceType; confidenceBand?: ResolutionConfidenceBand; }; pages: DocsReadPage[]; summary: string; implementationNotes: string[]; relatedLocalFileHints: RelatedLocalFileHint[]; alternateSources: Array<{ url: string; sourceType: DocsSourceType; confidence: number; }>; warnings: string[]; followUpSuggestions: string[]; } export interface CachedTaskBrief { key: string; rootDir?: string; taskText: string; brief: TaskDocsBrief; createdAt: string; updatedAt: string; } export interface CachedRepoProfile { key: string; profile: RepoProfile; createdAt: string; updatedAt: string; } export interface DetectedReference { name: string; type: DocType; version?: string; confidence: number; matchedFrom: string[]; } export interface DetectReferencesInput { taskText: string; rootDir?: string; filePaths?: string[]; skipDevDependencies?: boolean; } export interface EnsureDocsInput { canonicalName: string; version?: string; type?: DocType; rootDir?: string; force?: boolean; sourceUrl?: string; } export interface ResolveDocsSourceInput { name: string; version?: string; rootDir?: string; sourceUrl?: string; ignoreCache?: boolean; } export interface CompareDocsSourcesResult { packageName: string; canonicalPackage: string; status: DocResolutionStatus; confidenceBand: ResolutionConfidenceBand; cacheStatus: ResolutionCacheStatus; source?: DocsSourceCandidate; compareSources: DocsSourceCandidate[]; reasons: string[]; } export interface RefreshCachedSourceResult { packageName: string; canonicalPackage: string; refreshed: boolean; source?: CachedResolvedSource; resolution: DocsSourceResolutionResult; reasons: string[]; } export interface ReadDocsPageInput { nameOrUrl: string; topic?: string; rootDir?: string; } export interface GeneratedDocFile { relativePath: string; section: string; content: string; } export interface ResolutionDiagnostics { requestedName: string; canonicalName: string; sourceDecision: 'registry' | 'override' | 'dynamic'; versionDecision: 'explicit' | 'package' | 'latest_stable' | 'fallback_latest'; docsResolutionStatus?: DocResolutionStatus; } export interface ResolvedReference { entry: RegistryEntry; rootDir: string; resolvedVersion?: string; localPath: string; resolvedPackageName?: string; diagnostics: ResolutionDiagnostics; } export interface EnsureDocsResult { canonicalName: string; type: DocType; resolvedVersion?: string; status: 'created' | 'updated' | 'reused' | 'skipped'; normalizationAdapter?: 'generic' | 'stripe-api' | 'google-ads-api' | 'meta-marketing-api'; resolutionDiagnostics?: ResolutionDiagnostics; fetchStatus?: 'online' | 'offline-fallback'; qualityStatus?: 'ready' | 'degraded'; qualityIssues?: string[]; localPath: string; manifestPath: string; lastSyncedAt: string; sourceUrl: string; } export interface FetchedDocPage { title: string; body: string; sourceUrl: string; slug: string; fetchedAt: string; crawlDepth: number; contentHash: string; extractorUsed: FetchExtractor; } export interface FetchDocsResult { pages: FetchedDocPage[]; primaryPage: FetchedDocPage; sourceUrl: string; etag?: string; lastModified?: string; fetchStatus: 'online' | 'offline-fallback'; fallbackReason?: string; } export interface DocManifest { name: string; type: DocType; source_url: string; docs_base_url: string; resolved_version?: string; package_name?: string; local_path: string; manifest_path: string; index_path: string; files: string[]; last_synced_at: string; content_hash: string; etag?: string; last_modified?: string; normalization_adapter?: 'generic' | 'stripe-api' | 'google-ads-api' | 'meta-marketing-api'; resolution_diagnostics?: ResolutionDiagnostics; fetch_status: 'online' | 'offline-fallback'; quality_status: 'ready' | 'degraded'; quality_issues: string[]; } export interface SyncStateEntry { canonicalName: string; type: DocType; resolvedVersion?: string; localPath: string; manifestPath: string; lastSyncedAt: string; contentHash: string; } export interface SyncState { synced_docs: SyncStateEntry[]; } export interface SetupOptions { agents: AgentType[]; rootDir?: string; yes?: boolean; } export interface SetupResult { rootDir: string; agents: AgentType[]; createdPaths: string[]; updatedPaths: string[]; packageScriptsPatched: boolean; } export interface ToolConfig { packageName: string; mcpCommand: string; docsRoot: string; initializedAt: string; configuredAgents: AgentType[]; }