@@ -8,6 +8,8 @@ module LlmDocsBuilder
88 #
99 # @api private
1010 class OutputFormatter
11+ # Threshold percentage below which we consider there's no AI-optimized version
12+ NO_AI_VERSION_THRESHOLD = 5
1113 # Format bytes into human-readable string
1214 #
1315 # @param bytes [Integer] number of bytes
@@ -56,10 +58,16 @@ def self.display_comparison_results(result)
5658
5759 if result [ :reduction_bytes ] . positive?
5860 display_reduction ( result )
61+
62+ # Detect if there's no dedicated AI version
63+ if result [ :reduction_percent ] < NO_AI_VERSION_THRESHOLD
64+ display_no_ai_version_message ( result )
65+ end
5966 elsif result [ :reduction_bytes ] . negative?
6067 display_increase ( result )
6168 else
6269 puts 'Same size'
70+ display_no_ai_version_message ( result )
6371 end
6472
6573 puts '=' * 60
@@ -89,5 +97,43 @@ def self.display_increase(result)
8997 puts "Token increase: #{ format_number ( token_increase ) } tokens (#{ token_increase_percent } %)"
9098 puts "Factor: #{ result [ :factor ] } x larger"
9199 end
100+
101+ # Display message when no dedicated AI version is detected
102+ #
103+ # @param result [Hash] comparison results
104+ # @api private
105+ def self . display_no_ai_version_message ( result )
106+ puts ''
107+ puts 'WARNING: NO DEDICATED AI VERSION DETECTED'
108+ puts ''
109+ puts 'The server is returning nearly identical content to both human and AI'
110+ puts 'User-Agents, indicating no AI-optimized version is currently served.'
111+ puts ''
112+ puts 'POTENTIAL SAVINGS WITH AI OPTIMIZATION:'
113+ puts ''
114+ puts 'Based on typical documentation optimization results, you could expect:'
115+ puts ' • 67-95% token reduction (average 83%)'
116+ puts ' • 3-20x smaller file sizes'
117+ puts ' • Faster LLM processing times'
118+ puts ' • Reduced API costs for AI queries'
119+ puts ' • Improved response accuracy'
120+ puts ''
121+ puts "For this page specifically (~#{ format_number ( result [ :human_tokens ] ) } tokens):"
122+ puts " • Estimated savings: ~#{ format_number ( ( result [ :human_tokens ] * 0.83 ) . round ) } tokens (83% reduction)"
123+ puts " • Could reduce to: ~#{ format_number ( ( result [ :human_tokens ] * 0.17 ) . round ) } tokens"
124+ puts " • Potential size: ~#{ format_bytes ( ( result [ :human_size ] * 0.17 ) . round ) } "
125+ puts ''
126+ puts 'HOW TO IMPLEMENT AI-OPTIMIZED DOCUMENTATION:'
127+ puts ''
128+ puts '1. Transform your docs with llm-docs-builder:'
129+ puts ' llm-docs-builder bulk-transform --docs ./docs --config llm-docs-builder.yml'
130+ puts ''
131+ puts '2. Configure your web server to serve .md files to AI bots:'
132+ puts ' See: https://github.com/mensfeld/llm-docs-builder#serving-optimized-docs'
133+ puts ''
134+ puts '3. Measure your actual savings:'
135+ puts ' llm-docs-builder compare --url <your-url> --file <local-md>'
136+ puts ''
137+ end
92138 end
93139end
0 commit comments