@@ -358,8 +358,13 @@ init_config() {
358358 done
359359 debug " Final AVAILABLE_PROVIDERS: ${AVAILABLE_PROVIDERS[*]} "
360360
361- # Sort providers alphabetically
362- mapfile -t AVAILABLE_PROVIDERS < <( printf ' %s\n' " ${AVAILABLE_PROVIDERS[@]} " | sort)
361+ # Sort providers alphabetically (bash 3.2 compatible - no mapfile)
362+ local sorted_providers
363+ sorted_providers=$( printf ' %s\n' " ${AVAILABLE_PROVIDERS[@]} " | sort)
364+ AVAILABLE_PROVIDERS=()
365+ while IFS= read -r provider; do
366+ [[ -n " $provider " ]] && AVAILABLE_PROVIDERS+=(" $provider " )
367+ done <<< " $sorted_providers"
363368}
364369
365370# Fallback built-in configuration
@@ -659,36 +664,85 @@ cmd_config() {
659664cmd_config_init () {
660665 local user_config
661666 user_config=" $( get_user_config_path) "
662-
667+
663668 if [[ -f " $user_config " ]]; then
664669 echo " ⚠️ Configuration file already exists: $user_config "
665670 read -p " Overwrite? (y/N): " -n 1 -r
666671 echo
667672 echo
668673 [[ ! $REPLY =~ ^[Yy]$ ]] && return 1
669674 fi
670-
675+
671676 # Create directory if it doesn't exist
672677 mkdir -p " $( dirname " $user_config " ) "
673-
674- # Copy default configuration
675- local default_config
676- while IFS= read -r config_file; do
677- if [[ -f " $config_file " ]]; then
678- default_config=" $config_file "
679- break
680- fi
681- done < <( get_config_locations)
682-
678+
679+ # Try to copy from system/repo config first (excluding user config path)
680+ local default_config=" "
681+ local script_dir_config
682+ script_dir_config=" $( get_script_dir) /config/llm-env.conf"
683+
684+ if [[ -f " /usr/local/etc/llm-env/config.conf" ]]; then
685+ default_config=" /usr/local/etc/llm-env/config.conf"
686+ elif [[ -f " $script_dir_config " ]]; then
687+ default_config=" $script_dir_config "
688+ fi
689+
683690 if [[ -n " $default_config " ]]; then
684691 cp " $default_config " " $user_config "
685692 echo " ✅ Created user configuration: $user_config "
686693 echo " 💡 Edit this file to customize your providers and models"
687694 echo
688695 else
689- echo " ❌ No default configuration found to copy"
696+ # Generate default config inline (matches installer behavior)
697+ cat > " $user_config " << 'EOF '
698+ # LLM Environment Manager Configuration
699+ # This file defines available LLM providers and their settings
700+
701+ [openai]
702+ base_url=https://api.openai.com/v1
703+ api_key_var=LLM_OPENAI_API_KEY
704+ default_model=gpt-5
705+ description=Industry standard, highest quality
706+ enabled=true
707+
708+ [cerebras]
709+ base_url=https://api.cerebras.ai/v1
710+ api_key_var=LLM_CEREBRAS_API_KEY
711+ default_model=qwen-3-coder-480b
712+ description=Fast inference, great for coding
713+ enabled=true
714+
715+ [groq]
716+ base_url=https://api.groq.com/openai/v1
717+ api_key_var=LLM_GROQ_API_KEY
718+ default_model=openai/gpt-oss-120b
719+ description=Lightning-fast inference
720+ enabled=true
721+
722+ [openrouter]
723+ base_url=https://openrouter.ai/api/v1
724+ api_key_var=LLM_OPENROUTER_API_KEY
725+ default_model=deepseek/deepseek-chat-v3.1:free
726+ description=Free tier option
727+ enabled=true
728+
729+ [xai]
730+ base_url=https://api.x.ai/v1
731+ api_key_var=LLM_XAI_API_KEY
732+ default_model=grok-code-fast-1
733+ description=xAI Grok, excellent reasoning and coding capabilities
734+ enabled=false
735+
736+ [deepseek]
737+ base_url=https://api.deepseek.com/v1
738+ api_key_var=LLM_DEEPSEEK_API_KEY
739+ default_model=deepseek-chat
740+ description=DeepSeek, excellent coding and reasoning models
741+ enabled=false
742+ EOF
743+ echo " ✅ Created user configuration: $user_config "
744+ echo " 💡 Edit this file to customize your providers and models"
690745 echo
691- return 1
692746 fi
693747}
694748
0 commit comments