mission control for agent skills
Go agent-skillsagent-toolsai-agentsai-toolsai-workflowclaude-codeclicoding-agentscommand-line-tooldeveloper-toolsgoopencodeproductivity-toolsskill-discoveryskill-managementskillsterminal-appterminal-uituiworkflow-automation
Polish TUI layouts, agent filtering, and warnings display
alvinrealc3e50fe9df06
diff --git a/internal/tui/tui.go b/internal/tui/tui.goindex 224f484..86414d6 100644--- a/internal/tui/tui.go+++ b/internal/tui/tui.go@@ -279,8 +279,10 @@ func (m appModel) Update(msg tea.Msg) (tea.Model, tea.Cmd) {m.action = 0m.actionResult = nil} else if m.agent != "" {+ selectedKey := m.currentSelectedKey()+ previousSelected := m.selectedm.agent = ""- m.selected = 0+ m.restoreSelection(selectedKey, previousSelected)m.action = 0m.actionResult = nilm.viewport.GotoTop()@@ -312,14 +314,18 @@ func (m appModel) Update(msg tea.Msg) (tea.Model, tea.Cmd) {m.viewport.GotoTop()return m, loadSnapshot(m.cwd)case "a":+ selectedKey := m.currentSelectedKey()+ previousSelected := m.selectedm.agent = m.nextAgentFilter()- m.selected = 0+ m.restoreSelection(selectedKey, previousSelected)m.action = 0m.actionResult = nilm.viewport.GotoTop()case "A":+ selectedKey := m.currentSelectedKey()+ previousSelected := m.selectedm.agent = ""- m.selected = 0+ m.restoreSelection(selectedKey, previousSelected)m.action = 0m.actionResult = nilm.viewport.GotoTop()@@ -681,6 +687,28 @@ func skillKey(skill *model.Skill) string {return strings.Join([]string{string(skill.Scope), skill.Name, skill.CanonicalPath, skill.SkillPath}, "\x00")}+func (m appModel) currentSelectedKey() string {+ items := m.filteredSkills()+ if len(items) == 0 || m.selected < 0 || m.selected >= len(items) {+ return ""+ }+ return skillKey(items[m.selected])+}++func (m *appModel) restoreSelection(selectedKey string, fallback int) {+ items := m.filteredSkills()+ if selectedKey != "" {+ for i, skill := range items {+ if skillKey(skill) == selectedKey {+ m.selected = i+ return+ }+ }+ }+ m.selected = fallback+ m.clampSelection()+}+func sourceGroupKey(skill *model.Skill) string {info := sourceInfo(skill)if info.Source == "" {@@ -809,8 +837,7 @@ func (m appModel) View() string {left := leftStyle.Render(fitLines(viewModel.filterPane(layout.Left.ContentWidth), layout.Left.ContentHeight))list := listStyle.Render(fitLines(viewModel.listPane(layout.List.ContentHeight, layout.List.ContentWidth), layout.List.ContentHeight))detail := detailStyle.Render(viewModel.detailPane())- footer := fitToScreen(viewModel.footer(), layout.Width, 1)- view := lipgloss.JoinHorizontal(lipgloss.Top, left, list, detail) + "\n" + footer+ view := lipgloss.JoinHorizontal(lipgloss.Top, left, list, detail)if viewModel.running {return viewModel.runningOverlay(layout)}@@ -916,7 +943,7 @@ func (m appModel) listPane(height, width int) string {if issueErrors > 0 {label += fmt.Sprintf(" !%d", issueErrors)} else if issueWarnings > 0 {- label += fmt.Sprintf(" ⚠%d", issueWarnings)+ label += fmt.Sprintf(" ⚠ %d", issueWarnings)}var line stringif i == m.selected {@@ -1024,13 +1051,24 @@ func (m appModel) detailLines(width int) []string {}if len(view.HealthIssues) > 0 {- lines = append(lines, "", healthHeaderStyle.Render("Health Issues"))+ issueErrors, _ := healthIssueCounts(view.HealthIssues)+ headerStyle := warningStyle.Bold(true)+ header := "Warnings"+ if issueErrors > 0 {+ headerStyle = healthHeaderStyle+ header = "Health Issues"+ }+ lines = append(lines, "", headerStyle.Render(header))for _, issue := range view.HealthIssues {line := fmt.Sprintf("- %s: %s", issue.Type, issue.Message)if issue.Path != "" {line += " (" + issue.Path + ")"}- lines = append(lines, wrapText(line, width))+ style := warningStyle+ if issue.Severity == "error" {+ style = errorStyle+ }+ lines = append(lines, style.Render(wrapText(line, width)))}}@@ -1086,16 +1124,45 @@ func (m appModel) visibilitySummary(view display.SkillView, width int) []string}return []string{formatMetaLine("Visibility:", "no compatibility data for "+m.agentLabel(), width)}}+ detected := m.detectedAgentSet()visible := 0+ total := 0+ label := "agents"+ if len(detected) > 0 {+ label = "detected agents"+ }for _, visibility := range view.Visibility {+ if len(detected) > 0 && !detected[visibility.Agent] {+ continue+ }+ total++if visibility.Visible {visible++}}- val := fmt.Sprintf("Available to %d/%d agents", visible, len(view.Visibility))+ if total == 0 {+ label = "agents"+ total = len(view.Visibility)+ for _, visibility := range view.Visibility {+ if visibility.Visible {+ visible+++ }+ }+ }+ val := fmt.Sprintf("Available to %d/%d %s", visible, total, label)return []string{formatMetaLine("Visibility:", val, width)}}+func (m appModel) detectedAgentSet() map[string]bool {+ out := map[string]bool{}+ for _, agent := range m.result.Agents {+ if agent.Detected {+ out[agent.Name] = true+ }+ }+ return out+}+func (m appModel) commandsOverlay(layout appLayout) string {modalWidth := 70if layout.Width < modalWidth+4 {@@ -1267,20 +1334,6 @@ func (m appModel) runningOverlay(layout appLayout) string {return fitToScreen(lipgloss.Place(layout.Width, layout.Height, lipgloss.Center, lipgloss.Center, box), layout.Width, layout.Height)}-func (m appModel) footer() string {- mode := ""- selection := ""- if count := m.selectedCount(); count > 0 {- selection = fmt.Sprintf(" %s", lipgloss.NewStyle().Foreground(lipgloss.Color("117")).Bold(true).Render(fmt.Sprintf("%d selected", count))) + " : space toggle, esc clear"- }- if m.searching {- mode = " " + lipgloss.NewStyle().Foreground(lipgloss.Color("212")).Bold(true).Render("SEARCH MODE") + " : type to filter, esc/enter to leave"- } else if m.commands {- mode = " " + lipgloss.NewStyle().Foreground(lipgloss.Color("117")).Bold(true).Render("ACTION MODE") + " : j/k choose, enter run, c/esc close"- }- return dimStyle.Render("LazySkills "+appVersion) + selection + mode-}-func (m appModel) filteredSkills() []*model.Skill {query := strings.ToLower(m.search)out := make([]*model.Skill, 0, len(m.result.Skills))@@ -1542,7 +1595,7 @@ func newAppLayout(width, height int) appLayout {}leftOuter, listOuter, detailOuter := paneOuterWidths(width)- paneHeight := height - 1 // reserve one row for the footer+ paneHeight := heightlayout.Left = newPaneLayout(leftOuter, paneHeight)layout.List = newPaneLayout(listOuter, paneHeight)layout.Detail = newPaneLayout(detailOuter, paneHeight)diff --git a/internal/tui/tui_test.go b/internal/tui/tui_test.goindex 6a8e328..94d280f 100644--- a/internal/tui/tui_test.go+++ b/internal/tui/tui_test.go@@ -40,10 +40,10 @@ func TestErrorViewIsSanitized(t *testing.T) {}}-func TestViewRendersQuietVersionFooter(t *testing.T) {+func TestViewRendersWithoutFooter(t *testing.T) {m := appModel{width: 100, height: 30, result: model.ScanResult{Skills: []*model.Skill{{Name: "Build", Description: "Build desc", Scope: model.ScopeProject}}}}out := m.View()- if !strings.Contains(out, "LazySkills v1") || strings.Contains(out, "actions are guarded") || !strings.Contains(out, "Build") {+ if strings.Contains(out, "LazySkills v1") || strings.Contains(out, "actions are guarded") || !strings.Contains(out, "Build") {t.Fatalf("unexpected view: %s", out)}}@@ -147,6 +147,40 @@ func TestAgentFilterCanResetDirectlyToAll(t *testing.T) {}}+func TestAgentFilterPreservesSelectedSkill(t *testing.T) {+ m := appModel{width: 100, height: 30, selected: 2, result: model.ScanResult{+ Agents: []model.AgentState{{Name: "claude-code", Detected: true}, {Name: "opencode", Detected: true}},+ Skills: []*model.Skill{+ {Name: "OpenOnly", Scope: model.ScopeProject, ObservedPaths: []model.ObservedPath{{Agent: "opencode"}}},+ {Name: "Shared", Scope: model.ScopeProject, ObservedPaths: []model.ObservedPath{{Agent: "opencode"}, {Agent: "claude-code"}}},+ {Name: "ClaudeOnly", Scope: model.ScopeProject, ObservedPaths: []model.ObservedPath{{Agent: "claude-code"}}},+ },+ }}+ updated, _ := m.Update(tea.KeyMsg{Type: tea.KeyRunes, Runes: []rune{'a'}})+ next := updated.(appModel)+ items := next.filteredSkills()+ if next.agent != "claude-code" || len(items) <= next.selected || items[next.selected].Name != "ClaudeOnly" {+ t.Fatalf("expected agent switch to preserve ClaudeOnly, agent=%q selected=%d items=%#v", next.agent, next.selected, items)+ }+}++func TestClearingAgentFilterPreservesSelectedSkill(t *testing.T) {+ m := appModel{width: 100, height: 30, agent: "claude-code", selected: 1, result: model.ScanResult{+ Agents: []model.AgentState{{Name: "claude-code", Detected: true}},+ Skills: []*model.Skill{+ {Name: "OpenOnly", Scope: model.ScopeProject, ObservedPaths: []model.ObservedPath{{Agent: "opencode"}}},+ {Name: "Shared", Scope: model.ScopeProject, ObservedPaths: []model.ObservedPath{{Agent: "opencode"}, {Agent: "claude-code"}}},+ {Name: "ClaudeOnly", Scope: model.ScopeProject, ObservedPaths: []model.ObservedPath{{Agent: "claude-code"}}},+ },+ }}+ updated, _ := m.Update(tea.KeyMsg{Type: tea.KeyRunes, Runes: []rune{'A'}})+ next := updated.(appModel)+ items := next.filteredSkills()+ if next.agent != "" || len(items) <= next.selected || items[next.selected].Name != "ClaudeOnly" {+ t.Fatalf("expected clearing agent to preserve ClaudeOnly, agent=%q selected=%d items=%#v", next.agent, next.selected, items)+ }+}+func TestTopLevelScanHealthIsRenderedSanitized(t *testing.T) {m := appModel{width: 100, height: 30, result: model.ScanResult{HealthIssues: []model.HealthIssue{{Type: "corrupt_lock", Message: "bad\x1b[31m lock"}}}}out := m.View()@@ -215,7 +249,7 @@ func TestListRendersIssueRowsWithSeverityBadges(t *testing.T) {{Name: "Error", Scope: model.ScopeProject, HealthIssues: []model.HealthIssue{{Type: "missing_file", Severity: "error", Message: "missing SKILL.md"}}},}}}out := m.listPane(20, 80)- if !strings.Contains(out, "Warning [P] ⚠1") {+ if !strings.Contains(out, "Warning [P] ⚠ 1") {t.Fatalf("expected warning issue badge, got %q", out)}if !strings.Contains(out, "Error [P] !1") {@@ -226,6 +260,16 @@ func TestListRendersIssueRowsWithSeverityBadges(t *testing.T) {}}+func TestDetailRendersWarningOnlyIssuesAsWarnings(t *testing.T) {+ m := appModel{result: model.ScanResult{Skills: []*model.Skill{+ {Name: "Custom", Scope: model.ScopeGlobal, HealthIssues: []model.HealthIssue{{Type: "ghost_agent_skill", Severity: "warning", Message: "agent-specific skill"}}},+ }}}+ out := m.detailText(80)+ if !strings.Contains(out, "Warnings") || strings.Contains(out, "Health Issues") {+ t.Fatalf("expected warning-only detail section, got %q", out)+ }+}+func TestCommandPreviewToggle(t *testing.T) {m := appModel{}updated, _ := m.Update(tea.KeyMsg{Type: tea.KeyRunes, Runes: []rune{'c'}})@@ -357,7 +401,7 @@ func TestSpaceMarksSkillsAndEscClearsSelection(t *testing.T) {m := bulkActionTestModel(t.TempDir())updated, _ := m.Update(tea.KeyMsg{Type: tea.KeySpace})m = updated.(appModel)- if m.selectedCount() != 1 || !strings.Contains(m.View(), "1 selected") || !strings.Contains(m.View(), "● One") {+ if m.selectedCount() != 1 || !strings.Contains(m.View(), "● One") {t.Fatalf("expected one marked skill, count=%d view=%q", m.selectedCount(), m.View())}updated, _ = m.Update(tea.KeyMsg{Type: tea.KeyEsc})@@ -887,6 +931,15 @@ func TestVisibilityReasonTranslation(t *testing.T) {if len(linesAll) != 1 || !strings.Contains(linesAll[0], "Available to 1/3 agents") {t.Errorf("expected all-agents summary, got %v", linesAll)}+ mDetected := appModel{result: model.ScanResult{Agents: []model.AgentState{+ {Name: "claude-code", Detected: true},+ {Name: "opencode", Detected: true},+ {Name: "cursor", Detected: false},+ }}}+ linesDetected := mDetected.visibilitySummary(display.Skill(sk), 80)+ if len(linesDetected) != 1 || !strings.Contains(linesDetected[0], "Available to 1/2 detected agents") {+ t.Errorf("expected detected-agent summary, got %v", linesDetected)+ }mFiltered := appModel{agent: "claude-code"}linesFiltered := mFiltered.visibilitySummary(display.Skill(sk), 80)