/** * Token counting utilities for LLM context management * * Implements spec 069: Token Counting Utilities * * Uses tiktoken (official OpenAI tokenizer) for exact token counts. * Token count is the primary metric for Context Economy because: * - Predicts AI performance better than line count * - Research shows 39% performance drop in multi-turn contexts * - Quality degradation starts well before 50K token limits * * See spec 066 for research findings and threshold rationale. */ export interface TokenCount { total: number; files: { path: string; tokens: number; lines?: number; }[]; breakdown?: { code: number; prose: number; tables: number; frontmatter: number; }; } export interface TokenCounterOptions { detailed?: boolean; includeSubSpecs?: boolean; } /** * Token counter using tiktoken for exact token counts */ export declare class TokenCounter { private encoding; getEncoding(): Promise; /** * Clean up resources (important to prevent memory leaks) */ dispose(): void; /** * Count tokens in a string */ countString(text: string): Promise; /** * Count tokens in content (convenience method for analyze command) * Alias for countString - provided for clarity in command usage */ countTokensInContent(content: string): Promise; /** * Count tokens in a single file */ countFile(filePath: string, options?: TokenCounterOptions): Promise; /** * Count tokens in a spec (including sub-specs if requested) */ countSpec(specPath: string, options?: TokenCounterOptions): Promise; /** * Analyze token breakdown by content type */ analyzeBreakdown(content: string): Promise>; /** * Check if content fits within token limit */ isWithinLimit(count: TokenCount, limit: number): boolean; /** * Format token count for display */ formatCount(count: TokenCount, verbose?: boolean): string; /** * Get performance indicators based on token count * Based on research from spec 066 */ getPerformanceIndicators(tokenCount: number): { level: 'excellent' | 'good' | 'warning' | 'problem'; costMultiplier: number; effectiveness: number; recommendation: string; }; } /** * Convenience function to create, use, and dispose of a TokenCounter */ export declare function countTokens(input: string | { content: string; } | { filePath: string; } | { specPath: string; }, options?: TokenCounterOptions): Promise; //# sourceMappingURL=token-counter.d.ts.map