Skip to content

Commit bf547f9

Browse files
authored
no measurement info (#24)
1 parent fa6c367 commit bf547f9

6 files changed

Lines changed: 139 additions & 6 deletions

File tree

CHANGELOG.md

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,16 @@
11
# Changelog
22

3+
## 0.9.0 (2025-10-17)
4+
- [Feature] **No AI Version Detection** - The `compare` command now detects when websites don't serve AI-optimized versions.
5+
- Triggers when reduction is <5% (nearly identical content for human and AI User-Agents)
6+
- Displays prominent warning: "WARNING: NO DEDICATED AI VERSION DETECTED"
7+
- Shows potential savings estimates based on typical 83% reduction rate
8+
- Provides page-specific calculations (estimated token savings, potential size)
9+
- Includes implementation guide with actionable steps
10+
- Helps identify opportunities to optimize documentation
11+
- [Enhancement] Updated `OutputFormatter#display_comparison_results` to include marketing message for unoptimized sites.
12+
- [Enhancement] Added utility script `probe_karafka_simple.rb` for batch comparison testing.
13+
314
## 0.8.2 (2025-10-17)
415
- [Fix] Fixed Docker workflow test to properly invoke help command (use `generate --help` instead of `--help`).
516

Gemfile.lock

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
PATH
22
remote: .
33
specs:
4-
llm-docs-builder (0.8.2)
4+
llm-docs-builder (0.9.0)
55
zeitwerk (~> 2.6)
66

77
GEM

README.md

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -442,10 +442,6 @@ generate_toc: true
442442
normalize_whitespace: true
443443
```
444444

445-
## Contributing
446-
447-
Bug reports and pull requests welcome at [github.com/mensfeld/llm-docs-builder](https://github.com/mensfeld/llm-docs-builder).
448-
449445
## License
450446

451447
Available as open source under the [MIT License](https://opensource.org/licenses/MIT).

lib/llm_docs_builder/output_formatter.rb

Lines changed: 46 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -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
93139
end

lib/llm_docs_builder/version.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,5 +2,5 @@
22

33
module LlmDocsBuilder
44
# Current version of the LlmDocsBuilder gem
5-
VERSION = '0.8.2'
5+
VERSION = '0.9.0'
66
end

spec/output_formatter_spec.rb

Lines changed: 80 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -92,5 +92,85 @@
9292
described_class.display_comparison_results(result)
9393
end.to output(/Same size/).to_stdout
9494
end
95+
96+
it 'displays no AI version warning when reduction is less than 5%' do
97+
result = {
98+
human_size: 1000,
99+
ai_size: 960,
100+
reduction_bytes: 40,
101+
reduction_percent: 4,
102+
factor: 1.04,
103+
human_tokens: 250,
104+
ai_tokens: 240,
105+
token_reduction: 10,
106+
token_reduction_percent: 4,
107+
human_source: 'https://example.com (User-Agent: human)',
108+
ai_source: 'https://example.com (User-Agent: AI)'
109+
}
110+
111+
output = capture_stdout do
112+
described_class.display_comparison_results(result)
113+
end
114+
115+
expect(output).to include('WARNING: NO DEDICATED AI VERSION DETECTED')
116+
expect(output).to include('POTENTIAL SAVINGS WITH AI OPTIMIZATION')
117+
expect(output).to include('67-95% token reduction (average 83%)')
118+
expect(output).to include('For this page specifically (~250 tokens)')
119+
end
120+
121+
it 'displays no AI version warning when sizes are exactly equal' do
122+
result = {
123+
human_size: 1000,
124+
ai_size: 1000,
125+
reduction_bytes: 0,
126+
reduction_percent: 0,
127+
factor: 1.0,
128+
human_tokens: 250,
129+
ai_tokens: 250,
130+
token_reduction: 0,
131+
token_reduction_percent: 0,
132+
human_source: 'https://example.com (User-Agent: human)',
133+
ai_source: 'https://example.com (User-Agent: AI)'
134+
}
135+
136+
output = capture_stdout do
137+
described_class.display_comparison_results(result)
138+
end
139+
140+
expect(output).to include('WARNING: NO DEDICATED AI VERSION DETECTED')
141+
expect(output).to include('POTENTIAL SAVINGS WITH AI OPTIMIZATION')
142+
end
143+
144+
it 'does not display no AI version warning when reduction is 5% or more' do
145+
result = {
146+
human_size: 1000,
147+
ai_size: 950,
148+
reduction_bytes: 50,
149+
reduction_percent: 5,
150+
factor: 1.05,
151+
human_tokens: 250,
152+
ai_tokens: 237,
153+
token_reduction: 13,
154+
token_reduction_percent: 5,
155+
human_source: 'https://example.com (User-Agent: human)',
156+
ai_source: 'https://example.com (User-Agent: AI)'
157+
}
158+
159+
output = capture_stdout do
160+
described_class.display_comparison_results(result)
161+
end
162+
163+
expect(output).not_to include('WARNING: NO DEDICATED AI VERSION DETECTED')
164+
expect(output).to include('Reduction:')
165+
end
166+
end
167+
168+
def capture_stdout
169+
original_stdout = $stdout
170+
$stdout = StringIO.new
171+
yield
172+
$stdout.string
173+
ensure
174+
$stdout = original_stdout
95175
end
96176
end

0 commit comments

Comments
 (0)