@@ -3,17 +3,11 @@ import 'dotenv/config';
33import { writeFile , mkdir } from 'node:fs/promises' ;
44import path from 'node:path' ;
55import { fileURLToPath } from 'node:url' ;
6- import { Command } from 'commander' ;
76import { AnthropicProvider } from '../src/lib/anthropic.ts' ;
87import type { AnthropicBatchRequest } from '../src/lib/schemas.ts' ;
98import distilled_data from '../src/distilled.json' with { type : 'json' } ;
109import * as v from 'valibot' ;
1110
12- interface CliOptions {
13- dryRun: boolean ;
14- debug: boolean ;
15- }
16-
1711interface VerificationResult {
1812 slug: string ;
1913 status: 'ACCURATE' | 'NOT_ACCURATE' ;
@@ -49,17 +43,6 @@ const verification_output_schema = v.object({
4943 ) ,
5044} ) ;
5145
52- const program = new Command ( ) ;
53-
54- program
55- . name ( 'verify-distilled' )
56- . description (
57- 'Verify the accuracy of distilled summaries by comparing them to original documentation' ,
58- )
59- . version ( '1.0.0' )
60- . option ( '-d, --dry-run' , 'Show what would be verified without making API calls' , false )
61- . option ( '--debug' , 'Debug mode: process only 2 sections' , false ) ;
62-
6346const VERIFICATION_PROMPT = `You are tasked with verifying the accuracy of a distilled/condensed version of documentation against the original content.
6447
6548Your task:
@@ -115,44 +98,16 @@ function parse_verification_response(text: string): {
11598}
11699
117100async function main ( ) {
118- program . parse ( ) ;
119- const options = program . opts < CliOptions > ( ) ;
120-
121- const debug = options . debug || process . env . DEBUG_MODE === '1' ;
122-
123101 console . log ( '🔍 Starting distilled verification...\n' ) ;
124102
125- if ( options . dryRun ) {
126- console . log ( '🔍 DRY RUN MODE - No API calls will be made\n' ) ;
127- }
128- if ( debug ) {
129- console . log ( '🐛 DEBUG MODE - Will process only 2 sections\n' ) ;
130- }
131-
132103 const output_path = path . join ( current_dirname , '../src/distilled-verification.json' ) ;
133104
134105 // Load distilled data
135106 console . log ( '📂 Loading distilled.json...' ) ;
136107 const { summaries, content } = distilled_data ;
137108
138- const sections_to_verify = Object . keys ( summaries ) ;
139- console . log ( `Found ${ sections_to_verify . length } sections to verify` ) ;
140-
141- // Debug mode: limit to 2 sections
142- let sections = sections_to_verify ;
143- if ( debug ) {
144- console . log ( '\n🐛 Processing only 2 sections for debugging' ) ;
145- sections = sections_to_verify . slice ( 0 , 2 ) ;
146- }
147-
148- console . log ( `\n📋 Will verify ${ sections . length } sections` ) ;
149-
150- // Dry run mode: exit before API calls
151- if ( options . dryRun ) {
152- console . log ( '\n🔍 DRY RUN complete - no changes were made' ) ;
153- console . log ( `Would have verified ${ sections . length } sections` ) ;
154- return ;
155- }
109+ const sections = Object . keys ( summaries ) ;
110+ console . log ( `Found ${ sections . length } sections to verify\n` ) ;
156111
157112 // Check for API key
158113 const api_key = process . env . ANTHROPIC_API_KEY ;
@@ -164,7 +119,7 @@ async function main() {
164119 }
165120
166121 // Initialize Anthropic API
167- console . log ( '\n 🤖 Initializing Anthropic API...' ) ;
122+ console . log ( '🤖 Initializing Anthropic API...' ) ;
168123 const anthropic = new AnthropicProvider ( 'claude-sonnet-4-5-20250929' , api_key ) ;
169124
170125 // Prepare batch requests
@@ -177,7 +132,7 @@ async function main() {
177132 custom_id : `verify-${ index } ` ,
178133 params : {
179134 model : anthropic . get_model_identifier ( ) ,
180- max_tokens : 4096 , // Increased to allow full responses
135+ max_tokens : 4096 ,
181136 messages : [
182137 {
183138 role : 'user' ,
@@ -290,7 +245,7 @@ async function main() {
290245 const output_data : VerificationOutput = {
291246 generated_at : new Date ( ) . toISOString ( ) ,
292247 model : 'claude-sonnet-4-5-20250929' ,
293- total_sections : sections_to_verify . length ,
248+ total_sections : sections . length ,
294249 verified_sections : sections . length ,
295250 accurate_count,
296251 not_accurate_count,
@@ -307,7 +262,7 @@ async function main() {
307262
308263 // Print summary
309264 console . log ( '\n📊 Verification Summary:' ) ;
310- console . log ( ` Total sections: ${ sections_to_verify . length } ` ) ;
265+ console . log ( ` Total sections: ${ sections . length } ` ) ;
311266 console . log ( ` Verified sections: ${ sections . length } ` ) ;
312267 console . log (
313268 ` ✅ Accurate: ${ accurate_count } (${ ( ( accurate_count / sections . length ) * 100 ) . toFixed ( 1 ) } %)` ,
@@ -317,16 +272,17 @@ async function main() {
317272 ) ;
318273
319274 if ( not_accurate_count > 0 ) {
320- console . log ( '\n⚠️ Sections with issues:' ) ;
275+ console . log ( '\n⚠️ Sections with issues (first 10) :' ) ;
321276 verification_results
322277 . filter ( ( r ) => r . status === 'NOT_ACCURATE' )
323- . slice ( 0 , 10 ) // Show first 10
278+ . slice ( 0 , 10 )
324279 . forEach ( ( r ) => {
325280 console . log ( ` - ${ r . slug } : ${ r . reasoning } ` ) ;
326281 } ) ;
327282 if ( not_accurate_count > 10 ) {
328283 console . log ( ` ... and ${ not_accurate_count - 10 } more` ) ;
329284 }
285+ console . log ( '\n💡 Run `pnpm show-verification-errors` to see all issues' ) ;
330286 }
331287
332288 console . log ( `\n✅ Results written to: ${ output_path } ` ) ;
0 commit comments