@@ -108,12 +108,33 @@ impl eframe::App for App {
108108 ) . show ( ctx, |ui_panel| {
109109 if self . editor . is_open ( ) {
110110 ui:: editor_panel:: show ( ui_panel, & mut self . editor ) ;
111- } else if self . selected_provider . is_some ( ) {
111+ } else if let Some ( provider) = self . selected_provider {
112+ let root = self . scan_root ( ) ;
113+ let dir = scanner:: provider_dir ( provider, & root, self . scope ) ;
114+ ui_panel. horizontal ( |ui| {
115+ ui. label ( egui:: RichText :: new ( provider. label ( ) ) . font ( ui:: theme:: heading_font ( ) ) . color ( ui:: theme:: TEXT_PRIMARY ) ) ;
116+ ui. with_layout ( egui:: Layout :: right_to_left ( egui:: Align :: Center ) , |ui| {
117+ if ui. button ( "Open folder" ) . clicked ( ) { open_path ( & dir) ; }
118+ for md in instruction_files ( provider, & root, & dir, self . scope ) {
119+ let label = md. file_name ( ) . unwrap_or_default ( ) . to_string_lossy ( ) . to_string ( ) ;
120+ let exists = md. exists ( ) ;
121+ let btn_text = if exists { label. clone ( ) } else { format ! ( "+ {}" , label) } ;
122+ let color = if exists { ui:: theme:: TEXT_ACCENT } else { ui:: theme:: TEXT_DIM } ;
123+ if ui. button ( egui:: RichText :: new ( btn_text) . color ( color) . font ( ui:: theme:: small_font ( ) ) ) . clicked ( ) {
124+ if !exists {
125+ if let Some ( p) = md. parent ( ) { let _ = std:: fs:: create_dir_all ( p) ; }
126+ let _ = std:: fs:: write ( & md, format ! ( "# {} instructions\n " , provider. label( ) ) ) ;
127+ }
128+ self . editor . open ( md) ;
129+ }
130+ }
131+ } ) ;
132+ } ) ;
133+ ui_panel. add_space ( 4.0 ) ;
112134 let kinds = self . available_kinds ( ) ;
113135 ui:: item_list:: filter_tabs ( ui_panel, & mut self . filter , & kinds) ;
114136 ui_panel. add_space ( 8.0 ) ;
115137 let result = ui:: item_list:: show ( ui_panel, & self . items , self . filter ) ;
116- // handle toggle
117138 if let Some ( idx) = result. index {
118139 if idx < self . items . len ( ) {
119140 match toggler:: toggle_item ( & mut self . items [ idx] ) {
@@ -122,7 +143,6 @@ impl eframe::App for App {
122143 }
123144 }
124145 }
125- // handle edit
126146 if let Some ( idx) = result. edit {
127147 if idx < self . items . len ( ) && self . items [ idx] . editable {
128148 self . editor . open ( self . items [ idx] . path . clone ( ) ) ;
@@ -147,3 +167,28 @@ impl eframe::App for App {
147167 }
148168 }
149169}
170+
171+ fn open_path ( path : & std:: path:: Path ) {
172+ let _ = if cfg ! ( windows) {
173+ std:: process:: Command :: new ( "explorer" ) . arg ( path) . spawn ( )
174+ } else if cfg ! ( target_os = "macos" ) {
175+ std:: process:: Command :: new ( "open" ) . arg ( path) . spawn ( )
176+ } else {
177+ std:: process:: Command :: new ( "xdg-open" ) . arg ( path) . spawn ( )
178+ } ;
179+ }
180+
181+ fn instruction_files ( provider : ProviderId , root : & PathBuf , dir : & PathBuf , scope : Scope ) -> Vec < PathBuf > {
182+ match ( provider, scope) {
183+ ( ProviderId :: Claude , Scope :: Project ) => vec ! [ root. join( "CLAUDE.md" ) ] ,
184+ ( ProviderId :: Claude , Scope :: Global ) => vec ! [ dir. join( "CLAUDE.md" ) ] ,
185+ ( ProviderId :: Codex , Scope :: Project ) => vec ! [ root. join( "AGENTS.md" ) ] ,
186+ ( ProviderId :: Codex , Scope :: Global ) => vec ! [ dir. join( "AGENTS.md" ) ] ,
187+ ( ProviderId :: Gemini , Scope :: Project ) => vec ! [ root. join( "GEMINI.md" ) , root. join( "AGENTS.md" ) ] ,
188+ ( ProviderId :: Gemini , Scope :: Global ) => vec ! [ dir. join( "GEMINI.md" ) ] ,
189+ ( ProviderId :: Kiro , Scope :: Project ) => vec ! [ root. join( ".kiro" ) . join( "steering" ) . join( "instructions.md" ) ] ,
190+ ( ProviderId :: Kiro , Scope :: Global ) => vec ! [ dir. join( "steering" ) . join( "instructions.md" ) ] ,
191+ ( ProviderId :: OpenCode , Scope :: Project ) => vec ! [ root. join( "AGENTS.md" ) ] ,
192+ ( ProviderId :: OpenCode , Scope :: Global ) => vec ! [ dir. join( "AGENTS.md" ) ] ,
193+ }
194+ }
0 commit comments