import { ConsolaInstance } from 'consola'; declare function collectFiles(baseDir: string, options: { ig: any; extensionSet: Set | null; excludeFiles: string[] | null; includeFiles: string[] | null; excludeDirs: string[] | null; includeDirs: string[] | null; verbose: number; }): Promise; type TokenEncoder = "simple" | "p50k" | "o200k" | "cl100k"; type TokenLimiter = "sequential" | "truncated"; interface FileNode { name: string; path: string; type: "file" | "directory"; content?: string; language?: string; size?: number; tokens?: number; lastModified?: Date; children?: FileNode[]; } interface PerformanceMetrics { fetchDuration: number; parseFiles: number; tokenCountDuration: number; totalDuration: number; memoryUsed?: number; } interface FetchMetadata { totalFiles: number; totalSize: number; totalTokens: number; fetchedAt: Date; source: string; gitProvider?: string; gitOwner?: string; gitRepo?: string; gitRef?: string; metrics?: PerformanceMetrics; } interface FetchResult { root: FileNode; metadata: FetchMetadata; } type OutputFormat = "markdown" | "json"; declare function collectFilesAsTree(baseDir: string, files: string[], options?: { tokenEncoder?: string; tokenLimit?: number; }): Promise<{ root: FileNode; totalSize: number; totalTokens: number; }>; interface MarkdownGeneratorOptions { maxTokens: number | null; verbose?: number; projectTree?: number; tokenEncoder: TokenEncoder; disableLineNumbers?: boolean; tokenLimiter?: TokenLimiter; promptFile?: string; inlinePrompt?: string; templateVars?: Record; onVerbose?: (message: string, level: number) => void; projectTreeBaseDir?: string; projectTreeSkipIgnoreFiles?: boolean; } declare function readFileWithTokenLimit(file: string, tokenEncoder: TokenEncoder, remainingTokensRef: { value: number; }, disableLineNumbers: boolean, onVerbose?: (message: string, level: number) => void): Promise<{ lines: string[]; finalLineNumber: number; }>; declare function generateMarkdown(files: string[], options: MarkdownGeneratorOptions): Promise; declare const countTokens: (text: string, encoder: TokenEncoder) => Promise; interface CodefetchConfig { outputFile: string; outputPath: string; maxTokens: number; includeFiles?: string[]; excludeFiles?: string[]; includeDirs?: string[]; excludeDirs?: string[]; verbose: number; extensions?: string[]; defaultIgnore: boolean; gitignore: boolean; projectTree: number; projectTreeSkipIgnoreFiles: boolean; tokenEncoder: TokenEncoder; tokenLimiter: TokenLimiter; trackedModels?: string[]; dryRun?: boolean; disableLineNumbers?: boolean; tokenCountOnly?: boolean; noSummary?: boolean; defaultPromptFile: string; inlinePrompt?: string; defaultChat?: string; templateVars?: Record; format?: OutputFormat; excludeMarkdown?: boolean; } declare const getDefaultConfig: () => CodefetchConfig; declare function resolveCodefetchConfig(config: CodefetchConfig, cwd: string): Promise; declare function mergeWithCliArgs(config: CodefetchConfig, cliArgs: Partial): CodefetchConfig; declare function createCustomConfigMerger(): (obj: any, defaults: any) => any; declare function generateProjectTree(baseDir: string, maxLevel?: number): string; declare function generateProjectTreeFromFiles(baseDir: string, files: string[], maxLevel?: number): string; declare function processPromptTemplate(template: string, codebase: string, vars: Record): Promise; /** * Check if a template contains the CURRENT_CODEBASE placeholder */ declare function hasCodebasePlaceholder(template: string): boolean; declare function resolvePrompt(promptFile: string): Promise; declare const findProjectRoot: (startDir: string) => string; declare const detectLanguage: (fileName: string) => string; /** * Create a simple hash from a string * Uses a basic hashing algorithm suitable for cache keys */ declare function createHash(str: string): string; /** * Normalize path separators to forward slashes for cross-platform compatibility * This is especially useful in tests where we need consistent path representations */ declare function normalizePathSeparators(path: string): string; /** * Convert path to use platform-specific separators */ declare function toPlatformPath(path: string): string; declare const VALID_PROMPTS: Set; declare const VALID_ENCODERS: Set; declare const VALID_LIMITERS: Set; declare const DEFAULT_IGNORE_PATTERNS: string; declare class FetchResultImpl { root: FileNode; metadata: FetchMetadata; constructor(root: FileNode, metadata: FetchMetadata); /** * Get a file node by its path */ getFileByPath(path: string): FileNode | null; /** * Get all files as a flat array */ getAllFiles(): FileNode[]; /** * Convert to markdown format */ toMarkdown(): string; /** * Build tree string representation */ private buildTreeString; } /** * Cache interface for universal cache implementation */ interface CachedResult { metadata: CacheMetadata; content: any; type?: "filesystem" | "memory" | "serialized"; } interface CacheMetadata { url: string; fetchedAt: string; expiresAt: string; contentType?: string; headers?: Record; } interface CacheOptions { namespace?: string; ttl?: number; baseUrl?: string; maxSize?: number; } interface CacheInterface { /** * Get a cached value */ get(key: string): Promise; /** * Set a cached value */ set(key: string, value: any, ttl?: number): Promise; /** * Delete a cached value */ delete(key: string): Promise; /** * Clear all cached values */ clear(): Promise; /** * Check if a key exists in cache */ has(key: string): Promise; } type CacheStrategy = "auto" | "force" | "bypass" | "refresh" | "validate"; interface FetchOptions extends Partial { source?: string; format?: OutputFormat; cache?: boolean | CacheStrategy; cacheKey?: string; cacheTTL?: number; cacheNamespace?: string; cacheBaseUrl?: string; noCache?: boolean; excludeMarkdown?: boolean; } declare function fetch(options?: FetchOptions): Promise; declare const GIT_PROVIDERS: { readonly "github.com": { readonly type: "github"; readonly patterns: readonly [RegExp]; }; readonly "gitlab.com": { readonly type: "gitlab"; readonly patterns: readonly [RegExp, RegExp]; }; }; interface ParsedURL { type: "git-repository"; url: string; normalizedUrl: string; domain: string; path: string; /** * Logical git provider identifier (e.g. "github" | "gitlab") */ gitProvider: "github" | "gitlab"; /** * Full host/domain of the provider (e.g. "github.com") */ gitHost: keyof typeof GIT_PROVIDERS; gitOwner: string; gitRepo: string; gitRef?: string; } interface URLValidationResult { valid: boolean; error?: string; } /** * Validates a URL for security and format */ declare function validateURL(urlString: string): URLValidationResult; /** * Parses and normalizes a URL */ declare function parseURL(urlString: string): ParsedURL | null; /** * Extracts base domain from URL for caching */ declare function extractCacheKey(parsedUrl: ParsedURL): string; interface WebFetchConfig { url: string; cacheTTL?: number; branch?: string; noCache?: boolean; noApi?: boolean; githubToken?: string; } interface GitCloneOptions { branch?: string; depth?: number; singleBranch?: boolean; } interface CrawlOptions { maxDepth?: number; maxPages?: number; ignoreRobots?: boolean; ignoreCors?: boolean; followRedirects?: boolean; userAgent?: string; } interface CrawlResult { url: string; content: string; links: string[]; depth: number; error?: string; } declare function fetchFromWeb(url: string, options?: FetchOptions): Promise; /** * GitHub API client for Node.js environments * * NOTE: This module is NOT compatible with Cloudflare Workers. * For Worker environments, use github-tarball.ts which provides * a streaming implementation using native Worker APIs. */ interface GitHubApiOptions { token?: string; branch?: string; } declare class GitHubApiClient { private owner; private repo; private logger; private options; private baseUrl; private headers; constructor(owner: string, repo: string, logger: ConsolaInstance, options?: GitHubApiOptions); /** * Check if the repository is accessible via API */ checkAccess(): Promise<{ accessible: boolean; isPrivate: boolean; defaultBranch: string; }>; /** * Download repository as ZIP archive */ downloadZipArchive(ref?: string): Promise; /** * Download and extract repository to a directory */ downloadToDirectory(targetDir: string, options?: { extensions?: string[]; excludeDirs?: string[]; maxFiles?: number; }): Promise; } /** * Fetch GitHub repository using API */ declare function fetchGitHubViaApi(parsedUrl: ParsedURL, targetDir: string, logger: ConsolaInstance, options?: { branch?: string; token?: string; extensions?: string[]; excludeDirs?: string[]; maxFiles?: number; }): Promise; /** * Cache factory that returns the appropriate cache implementation based on runtime environment */ /** * Create a cache instance based on the runtime environment */ declare function createCache(options?: CacheOptions): Promise; export { type CodefetchConfig, type CrawlOptions, type CrawlResult, DEFAULT_IGNORE_PATTERNS, type FetchMetadata, type FetchOptions, type FetchResult, FetchResultImpl, type FileNode, type GitCloneOptions, GitHubApiClient, type MarkdownGeneratorOptions, type OutputFormat, type ParsedURL, type PerformanceMetrics, type TokenEncoder, type TokenLimiter, type URLValidationResult, VALID_ENCODERS, VALID_LIMITERS, VALID_PROMPTS, type WebFetchConfig, collectFiles, collectFilesAsTree, countTokens, createCache, createCustomConfigMerger, createHash, detectLanguage, extractCacheKey, fetch, fetchFromWeb, fetchGitHubViaApi, findProjectRoot, generateMarkdown, generateProjectTree, generateProjectTreeFromFiles, getDefaultConfig, hasCodebasePlaceholder, mergeWithCliArgs, normalizePathSeparators, parseURL, processPromptTemplate, readFileWithTokenLimit, resolveCodefetchConfig, resolvePrompt, toPlatformPath, validateURL };