@@ -1285,10 +1285,13 @@ def list_available_pythons(self) -> Dict[str, str]:
12851285
12861286 def _first_time_setup (self , interactive = True ) -> Dict :
12871287 """Interactive setup for the first time the tool is run."""
1288+ import os # <--- ADD THIS LINE
12881289 self .config_dir .mkdir (parents = True , exist_ok = True )
12891290 defaults = self ._get_sensible_defaults ()
12901291 final_config = defaults .copy ()
1291- if interactive :
1292+
1293+ # vvv CHANGE THIS LINE vvv
1294+ if interactive and not os .environ .get ('CI' ):
12921295 print (_ ("🌍 Welcome to omnipkg! Let's get you configured." ))
12931296 print ('-' * 60 )
12941297 available_pythons = defaults ['python_interpreters' ]
@@ -1331,11 +1334,37 @@ def _first_time_setup(self, interactive=True) -> Dict:
13311334 full_config ['environments' ][self .env_id ] = final_config
13321335 with open (self .config_path , 'w' ) as f :
13331336 json .dump (full_config , f , indent = 4 )
1334- if interactive :
1337+ if interactive and not os . environ . get ( 'CI' ): # Also add the check here to avoid printing the final message
13351338 print (_ ('\n ✅ Configuration saved to {}.' ).format (self .config_path ))
13361339 print (_ (' You can edit this file manually later.' ))
1337- rebuild_cmd = [str (python_path ), "-m" , "omnipkg.cli" , "reset" , "-y" ]
1338- subprocess .run (rebuild_cmd , check = True , capture_output = True , text = True )
1340+ print (_ ('🧠 Initializing omnipkg knowledge base...' ))
1341+ print (_ (' This may take a moment with large environments (like yours with {} packages).' ).format (len (defaults .get ('installed_packages' , []))))
1342+ print (_ (' 💡 Future startups will be instant!' ))
1343+
1344+ # Run the rebuild with proper error handling and progress indication
1345+ rebuild_cmd = [str (final_config ['python_executable' ]), "-m" , "omnipkg.cli" , "reset" , "-y" ]
1346+ try :
1347+ if interactive and not os .environ .get ('CI' ):
1348+ # Show progress for interactive mode
1349+ process = subprocess .Popen (rebuild_cmd , stdout = subprocess .PIPE , stderr = subprocess .STDOUT , text = True )
1350+ while True :
1351+ output = process .stdout .readline ()
1352+ if output == '' and process .poll () is not None :
1353+ break
1354+ if output and ('Processing' in output or 'Building' in output or 'Scanning' in output ):
1355+ print (f" { output .strip ()} " )
1356+ process .wait ()
1357+ if process .returncode != 0 :
1358+ print (_ (' ⚠️ Knowledge base initialization encountered issues but continuing...' ))
1359+ else :
1360+ # Silent mode for CI
1361+ subprocess .run (rebuild_cmd , check = True , capture_output = True , text = True )
1362+ except subprocess .CalledProcessError as e :
1363+ if interactive and not os .environ .get ('CI' ):
1364+ print (_ (' ⚠️ Knowledge base will be built on first command usage instead.' ))
1365+ # Don't fail setup if rebuild fails - it can be done later
1366+ pass
1367+
13391368 return final_config
13401369
13411370 def _load_or_create_env_config (self ) -> Dict :
0 commit comments