package tui import ( "fmt" "regexp" "strings" "github.com/charmbracelet/lipgloss" ) var versionRegex = regexp.MustCompile(`\d+\.\d+\.\d+`) func extractVersion(s string) string { return versionRegex.FindString(s) } func (m Model) renderConfig() string { var b strings.Builder b.WriteString(sectionStyle.Render("Profile")) b.WriteString("\n") if m.config != nil { fields := []struct { label string value string }{ {"Name", m.config.Profile.Name}, {"Pseudo", m.config.Profile.Pseudo}, {"Email", m.config.Profile.Email}, {"Editor", m.config.Profile.Preferences.Editor}, {"Shell", m.config.Profile.Preferences.Shell}, {"Theme", m.config.Profile.Preferences.Theme}, {"Default AI", m.config.Profile.Preferences.DefaultAI}, } for _, f := range fields { labelStyle := lipgloss.NewStyle().Foreground(mutedColor).Width(14) valueStyle := lipgloss.NewStyle().Foreground(lipgloss.Color("#E0E0E0")) b.WriteString(fmt.Sprintf(" %s %s\n", labelStyle.Render(f.label+":"), valueStyle.Render(f.value))) } if len(m.config.Profile.Languages) > 0 { labelStyle := lipgloss.NewStyle().Foreground(mutedColor).Width(14) valueStyle := lipgloss.NewStyle().Foreground(lipgloss.Color("#E0E0E0")) b.WriteString(fmt.Sprintf(" %s %s\n", labelStyle.Render("Languages:"), valueStyle.Render(strings.Join(m.config.Profile.Languages, ", ")))) } } b.WriteString("\n") b.WriteString(sectionStyle.Render("AI Providers")) b.WriteString("\n") if m.config != nil { for _, p := range m.config.AI.Providers { active := "" if p.Active { active = itemOKStyle.Render(" active") } keyStatus := itemMissingStyle.Render("no key") if p.APIKey != "" { keyStatus = itemOKStyle.Render("configured") } nameStyle := lipgloss.NewStyle().Foreground(lipgloss.Color("#E0E0E0")).Bold(true) b.WriteString(fmt.Sprintf(" %s model=%s key=%s%s\n", nameStyle.Render(p.Name), p.Model, keyStatus, active)) } } b.WriteString("\n") b.WriteString(sectionStyle.Render("BMAD Method")) b.WriteString("\n") if m.config != nil { installed := itemMissingStyle.Render("no") if m.config.BMAD.Installed { installed = itemOKStyle.Render("yes") } b.WriteString(fmt.Sprintf(" Installed: %s\n", installed)) b.WriteString(fmt.Sprintf(" Global: %v\n", m.config.BMAD.Global)) } b.WriteString("\n") b.WriteString(sectionStyle.Render("Terminal")) b.WriteString("\n") if m.config != nil { b.WriteString(fmt.Sprintf(" Custom Prompt: %v\n", m.config.Terminal.CustomPrompt)) b.WriteString(fmt.Sprintf(" Prompt Theme: %s\n", m.config.Terminal.PromptTheme)) } b.WriteString("\n") b.WriteString(sectionStyle.Render(fmt.Sprintf("Skills (%d)", len(m.skillList)))) b.WriteString("\n") if len(m.skillList) > 0 { for _, s := range m.skillList { target := s.Target if target == "" { target = "both" } b.WriteString(fmt.Sprintf(" %-20s %s %s\n", lipgloss.NewStyle().Foreground(lipgloss.Color("#E0E0E0")).Render(s.Name), lipgloss.NewStyle().Foreground(aiColor).Render("["+target+"]"), s.Description)) } } else { b.WriteString(" No skills. Run `muyue skills init` to install built-ins.\n") } return b.String() }