@@ -24,6 +24,7 @@ import {
2424 parseDate ,
2525 resolveByIdPrefix ,
2626} from './utils' ;
27+ import { colorize } from '../formatters' ;
2728
2829export type SelectionResult = { selected : SearchMatch ; matches : SearchMatch [ ] ; limit : number } ;
2930
@@ -331,12 +332,15 @@ export async function printExplore(options: ExploreRenderOptions) {
331332 options . longIds ? id : formatNodeIdProgressive ( id , allNodes ) ;
332333
333334 console . log ( '' ) ;
334- console . log ( 'suggested edges:' ) ;
335+ console . log ( ` ${ colorize . label ( 'suggested edges:' ) } ` ) ;
335336 for ( const suggestion of suggestionData ) {
336337 const [ sa , sb ] = suggestion . id . split ( '::' ) ;
337338 const code = sa && sb ? getEdgePrefix ( sa , sb , allEdges ) : '????' ;
339+ const coloredScore = colorize . aggregateScore ( suggestion . score ) ;
340+ const coloredCode = colorize . edgeCode ( code ) ;
341+ const coloredId = colorize . nodeId ( formatNodeId ( suggestion . otherId ) ) ;
338342 console . log (
339- ` ${ formatScore ( suggestion . score ) } [${ code } ] ${ formatNodeId ( suggestion . otherId ) } ${ suggestion . otherTitle } ` ,
343+ ` ${ coloredScore } [${ coloredCode } ] ${ coloredId } ${ suggestion . otherTitle } ` ,
340344 ) ;
341345 }
342346 }
@@ -353,23 +357,26 @@ export async function printNodeOverview(
353357 const formatNodeId = ( id : string ) =>
354358 options . longIds ? id : formatNodeIdProgressive ( id , allNodes ) ;
355359
356- console . log ( `${ formatNodeId ( node . id ) } ${ node . title } ` ) ;
360+ console . log ( `${ colorize . nodeId ( formatNodeId ( node . id ) ) } ${ node . title } ` ) ;
357361 if ( node . tags . length > 0 ) {
358- console . log ( `tags: ${ node . tags . join ( ', ' ) } ` ) ;
362+ const tagLabels = node . tags . map ( tag => colorize . tag ( tag ) ) . join ( ', ' ) ;
363+ console . log ( `${ colorize . label ( 'tags:' ) } ${ tagLabels } ` ) ;
359364 }
360- console . log ( `created: ${ node . createdAt } ` ) ;
361- console . log ( `updated: ${ node . updatedAt } ` ) ;
365+ console . log ( `${ colorize . label ( ' created:' ) } ${ node . createdAt } ` ) ;
366+ console . log ( `${ colorize . label ( ' updated:' ) } ${ node . updatedAt } ` ) ;
362367 console . log ( '' ) ;
363368
364369 if ( directEdges . length > 0 ) {
365- console . log ( 'accepted edges:' ) ;
370+ console . log ( ` ${ colorize . label ( 'accepted edges:' ) } ` ) ;
366371 for ( const edge of directEdges ) {
372+ const coloredScore = colorize . embeddingScore ( edge . score ) ;
373+ const coloredId = colorize . nodeId ( formatNodeId ( edge . otherId ) ) ;
367374 console . log (
368- ` ${ formatScore ( edge . score ) } ${ formatNodeId ( edge . otherId ) } ${ edge . otherTitle } ` ,
375+ ` ${ coloredScore } ${ coloredId } ${ edge . otherTitle } ` ,
369376 ) ;
370377 }
371378 } else {
372- console . log ( 'accepted edges: none' ) ;
379+ console . log ( ` ${ colorize . label ( 'accepted edges:' ) } none` ) ;
373380 }
374381}
375382
@@ -389,9 +396,13 @@ async function printMatches(
389396 const limit = Math . min ( matches . length , options . limit ?? DEFAULT_MATCH_DISPLAY_LIMIT ) ;
390397 for ( let index = 0 ; index < limit ; index += 1 ) {
391398 const entry = matches [ index ] ;
392- const tags = entry . node . tags . length > 0 ? ` [${ entry . node . tags . join ( ', ' ) } ]` : '' ;
399+ const coloredScore = colorize . embeddingScore ( entry . score ) ;
400+ const coloredId = colorize . nodeId ( formatNodeId ( entry . node . id ) ) ;
401+ const tags = entry . node . tags . length > 0
402+ ? ` [${ entry . node . tags . map ( tag => colorize . tag ( tag ) ) . join ( ', ' ) } ]`
403+ : '' ;
393404 console . log (
394- `${ index + 1 } . ${ formatScore ( entry . score ) } ${ formatNodeId ( entry . node . id ) } ${
405+ `${ index + 1 } . ${ coloredScore } ${ coloredId } ${
395406 entry . node . title
396407 } ${ tags } `,
397408 ) ;
0 commit comments