@@ -2,10 +2,7 @@ import { createProjectState, type ProjectState } from '../project-state.js';
22import { handle as searchCodebaseHandle } from '../tools/search-codebase.js' ;
33import { handle as getCodebaseMetadataHandle } from '../tools/get-codebase-metadata.js' ;
44import { handle as getTeamPatternsHandle } from '../tools/get-team-patterns.js' ;
5- import type {
6- SearchResponse ,
7- PatternResponse
8- } from '../tools/types.js' ;
5+ import type { SearchResponse , PatternResponse } from '../tools/types.js' ;
96import type {
107 DiscoveryBenchmarkProtocol ,
118 DiscoveryComparatorEvidence ,
@@ -45,7 +42,10 @@ function createToolProject(rootPath: string): ProjectState {
4542 return project ;
4643}
4744
48- async function runSearchCodebase ( task : DiscoveryTaskType , rootPath : string ) : Promise < DiscoverySurfaceResultType > {
45+ async function runSearchCodebase (
46+ task : DiscoveryTaskType ,
47+ rootPath : string
48+ ) : Promise < DiscoverySurfaceResultType > {
4949 const project = createToolProject ( rootPath ) ;
5050 const response = await searchCodebaseHandle ( task . args ?? { query : task . prompt } , {
5151 indexState : project . indexState ,
@@ -62,7 +62,7 @@ async function runSearchCodebase(task: DiscoveryTaskType, rootPath: string): Pro
6262 const preflight = parsed . preflight ;
6363 const bestExample =
6464 preflight && typeof preflight === 'object' && preflight !== null && 'bestExample' in preflight
65- ? ( preflight . bestExample as string | undefined ) ?? null
65+ ? ( ( preflight . bestExample as string | undefined ) ?? null )
6666 : null ;
6767
6868 return {
@@ -77,12 +77,15 @@ async function runCodebaseMetadata(
7777 rootPath : string
7878) : Promise < DiscoverySurfaceResultType > {
7979 const project = createToolProject ( rootPath ) ;
80- const response = await getCodebaseMetadataHandle ( { } , {
81- indexState : project . indexState ,
82- paths : project . paths ,
83- rootPath : project . rootPath ,
84- performIndexing : ( ) => undefined
85- } ) ;
80+ const response = await getCodebaseMetadataHandle (
81+ { } ,
82+ {
83+ indexState : project . indexState ,
84+ paths : project . paths ,
85+ rootPath : project . rootPath ,
86+ performIndexing : ( ) => undefined
87+ }
88+ ) ;
8689 return { payload : response . content ?. [ 0 ] ?. text ?? '{}' } ;
8790}
8891
@@ -146,9 +149,7 @@ function evaluateDiscoveryTask(
146149 const matchedSignals = task . expectedSignals . filter ( ( signal ) =>
147150 normalizedPayload . includes ( normalizeText ( signal ) )
148151 ) ;
149- const missingSignals = task . expectedSignals . filter (
150- ( signal ) => ! matchedSignals . includes ( signal )
151- ) ;
152+ const missingSignals = task . expectedSignals . filter ( ( signal ) => ! matchedSignals . includes ( signal ) ) ;
152153 const forbiddenHits = ( task . forbiddenSignals ?? [ ] ) . filter ( ( signal ) =>
153154 normalizedPayload . includes ( normalizeText ( signal ) )
154155 ) ;
@@ -190,9 +191,7 @@ function summarizeDiscoveryResults(results: DiscoveryTaskResultEval[]): Discover
190191 ? results . reduce ( ( sum , result ) => sum + result . usefulnessScore , 0 ) / totalTasks
191192 : 0 ;
192193 const averagePayloadBytes =
193- totalTasks > 0
194- ? results . reduce ( ( sum , result ) => sum + result . payloadBytes , 0 ) / totalTasks
195- : 0 ;
194+ totalTasks > 0 ? results . reduce ( ( sum , result ) => sum + result . payloadBytes , 0 ) / totalTasks : 0 ;
196195 const averageEstimatedTokens =
197196 totalTasks > 0
198197 ? results . reduce ( ( sum , result ) => sum + result . estimatedTokens , 0 ) / totalTasks
@@ -241,8 +240,7 @@ function compareMetric(
241240 comparatorValue : number | null ,
242241 metric : DiscoveryMetricName
243242) : DiscoveryMetricComparison {
244- const lowerIsBetter =
245- metric === 'averageEstimatedTokens' || metric === 'averageFirstRelevantHit' ;
243+ const lowerIsBetter = metric === 'averageEstimatedTokens' || metric === 'averageFirstRelevantHit' ;
246244 const passes =
247245 actualValue !== null &&
248246 comparatorValue !== null &&
@@ -359,9 +357,7 @@ function evaluateComparatorGate(
359357 } ;
360358}
361359
362- export function combineDiscoverySummaries (
363- summaries : DiscoverySummaryType [ ]
364- ) : DiscoverySummaryType {
360+ export function combineDiscoverySummaries ( summaries : DiscoverySummaryType [ ] ) : DiscoverySummaryType {
365361 return summarizeDiscoveryResults ( summaries . flatMap ( ( summary ) => summary . results ) ) ;
366362}
367363
@@ -399,7 +395,8 @@ export function evaluateDiscoveryGate({
399395 const status =
400396 missingEvidence . length > 0
401397 ? 'pending_evidence'
402- : baseline . status === 'passed' && comparators . every ( ( comparator ) => comparator . status === 'passed' )
398+ : baseline . status === 'passed' &&
399+ comparators . every ( ( comparator ) => comparator . status === 'passed' )
403400 ? 'passed'
404401 : 'failed' ;
405402
@@ -447,9 +444,7 @@ export function formatDiscoveryReport({
447444 lines . push ( `Average estimated tokens: ${ Math . round ( summary . averageEstimatedTokens ) } ` ) ;
448445 lines . push (
449446 `Average first relevant hit: ${
450- summary . averageFirstRelevantHit === null
451- ? 'n/a'
452- : summary . averageFirstRelevantHit . toFixed ( 2 )
447+ summary . averageFirstRelevantHit === null ? 'n/a' : summary . averageFirstRelevantHit . toFixed ( 2 )
453448 } `
454449 ) ;
455450 lines . push (
0 commit comments