@@ -10,19 +10,21 @@ import {
1010 outputSessionStartContent
1111} from '../prompts/templates/context/ContextTemplates.js' ;
1212
13- interface IndexEntry {
14- summary : string ;
15- entity : string ;
16- keywords : string [ ] ;
17- }
18-
1913interface TrashStatus {
2014 folderCount : number ;
2115 fileCount : number ;
2216 totalSize : number ;
2317 isEmpty : boolean ;
2418}
2519
20+ function buildProjectMatcher ( projectName : string ) : ( value ?: string ) => boolean {
21+ const aliases = new Set < string > ( ) ;
22+ aliases . add ( projectName ) ;
23+ aliases . add ( projectName . replace ( / - / g, '_' ) ) ;
24+ aliases . add ( projectName . replace ( / _ / g, '-' ) ) ;
25+ return ( value ?: string ) => ! ! value && aliases . has ( value ) ;
26+ }
27+
2628function formatSize ( bytes : number ) : string {
2729 if ( bytes === 0 ) return '0 B' ;
2830 const k = 1024 ;
@@ -115,20 +117,25 @@ export async function loadContext(options: OptionValues = {}): Promise<void> {
115117 const sessions = jsonObjects . filter ( obj => obj . type === 'session' ) ;
116118
117119 // Filter each type by project if specified
120+ // Handle both hyphen and underscore formats since index has mixed entries
118121 let filteredMemories = memories ;
119122 let filteredOverviews = overviews ;
123+ let filteredSessions = sessions ;
120124 if ( options . project ) {
121- filteredMemories = memories . filter ( obj => obj . project === options . project ) ;
122- filteredOverviews = overviews . filter ( obj => obj . project === options . project ) ;
125+ const matchesProject = buildProjectMatcher ( options . project ) ;
126+ filteredMemories = memories . filter ( obj => matchesProject ( obj . project ) ) ;
127+ filteredOverviews = overviews . filter ( obj => matchesProject ( obj . project ) ) ;
128+ filteredSessions = sessions . filter ( obj => matchesProject ( obj . project ) ) ;
123129 }
124130
125131 if ( options . format === 'session-start' ) {
126132 // Get last 10 memories and last 5 overviews for session-start
127133 const recentMemories = filteredMemories . slice ( - 10 ) ;
128134 const recentOverviews = filteredOverviews . slice ( - 5 ) ;
135+ const recentSessions = filteredSessions . slice ( - 5 ) ;
129136
130137 // Combine them for the display
131- const recentObjects = [ ...recentMemories , ...recentOverviews ] ;
138+ const recentObjects = [ ...recentSessions , ... recentMemories , ...recentOverviews ] ;
132139
133140 // Find most recent timestamp for last session info
134141 let lastSessionTime = 'recently' ;
@@ -195,4 +202,4 @@ export async function loadContext(options: OptionValues = {}): Promise<void> {
195202 console . log ( createUserFriendlyError ( 'Context loading' , errorMessage , 'Check file permissions and try again' ) ) ;
196203 }
197204 }
198- }
205+ }
0 commit comments