mission control for agent skills
Go agent-skillsagent-toolsai-agentsai-toolsai-workflowclaude-codeclicoding-agentscommand-line-tooldeveloper-toolsgoopencodeproductivity-toolsskill-discoveryskill-managementskillsterminal-appterminal-uituiworkflow-automation
fix: improve registry skill previews
Alvin Unreala8485d78422a
diff --git a/internal/tui/tui.go b/internal/tui/tui.goindex 2a44e53..7dab855 100644--- a/internal/tui/tui.go+++ b/internal/tui/tui.go@@ -118,6 +118,7 @@ type appModel struct {registryGeneration intregistryFocusList boolregistrySelectedKeys map[string]registry.Skill+ registryPreviews map[string]stringconfirmReturnRegistry bool}@@ -231,6 +232,7 @@ func newModel(cwd string) appModel {collapsedGroups: make(map[string]bool),discovery: make(map[string]SourceDiscovery),previewCache: make(map[previewCacheKey][]string),+ registryPreviews: make(map[string]string),}}diff --git a/internal/tui/update.go b/internal/tui/update.goindex 3f890a3..e995843 100644--- a/internal/tui/update.go+++ b/internal/tui/update.go@@ -3,6 +3,8 @@ package tuiimport ("context""fmt"+ "io"+ "net/http""os""os/exec""path/filepath"@@ -181,7 +183,15 @@ func (m appModel) Update(msg tea.Msg) (tea.Model, tea.Cmd) {m.registryError = msg.errm.registrySelected = 0m.syncViewport()+ return m, m.currentRegistryPreviewCmd()}+ case registryPreviewMsg:+ if m.registryPreviews == nil {+ m.registryPreviews = make(map[string]string)+ }+ m.registryPreviews[msg.key] = msg.content+ m.syncViewport()+ return m, nilcase tea.KeyMsg:key := msg.String()var postKeyCmd tea.Cmd@@ -226,6 +236,7 @@ func (m appModel) Update(msg tea.Msg) (tea.Model, tea.Cmd) {m.registrySelected = len(m.registryResults) - 1}m.syncViewport()+ return m, m.currentRegistryPreviewCmd()}return m, nilcase "down", "j":@@ -235,6 +246,7 @@ func (m appModel) Update(msg tea.Msg) (tea.Model, tea.Cmd) {m.registrySelected = 0}m.syncViewport()+ return m, m.currentRegistryPreviewCmd()}return m, nilcase " ":@@ -1920,3 +1932,92 @@ func scheduleRegistrySearch(query string, generation int) tea.Cmd {return registryDebounceMsg{generation: generation, query: query}})}++type registryPreviewMsg struct {+ key string+ content string+}++func deriveRawGitHubURLs(source string) []string {+ repo, folder := parseSourceURLDetails(source)+ parts := strings.Split(repo, "/")+ if len(parts) < 2 {+ return nil+ }+ owner, name := parts[0], parts[1]++ var urls []string+ branches := []string{"main", "master"}+ files := []string{"SKILL.md", "README.md", "README"}++ for _, branch := range branches {+ for _, file := range files {+ var path string+ if folder != "" {+ path = folder + "/" + file+ } else {+ path = file+ }+ urls = append(urls, fmt.Sprintf("https://raw.githubusercontent.com/%s/%s/%s/%s", owner, name, branch, path))+ }+ }+ return urls+}++func (m appModel) fetchRegistryPreviewCmd(key string, source string) tea.Cmd {+ return func() tea.Msg {+ urls := deriveRawGitHubURLs(source)+ if len(urls) == 0 {+ return registryPreviewMsg{key: key, content: ""}+ }++ client := &http.Client{Timeout: 3 * time.Second}+ for _, u := range urls {+ req, err := http.NewRequest("GET", u, nil)+ if err != nil {+ continue+ }+ resp, err := client.Do(req)+ if err != nil {+ continue+ }+ if resp.StatusCode == http.StatusOK {+ bodyBytes, err := io.ReadAll(resp.Body)+ resp.Body.Close()+ if err == nil && len(bodyBytes) > 0 {+ return registryPreviewMsg{+ key: key,+ content: string(bodyBytes),+ }+ }+ }+ resp.Body.Close()+ }+ return registryPreviewMsg{key: key, content: ""}+ }+}++func (m appModel) currentRegistryPreviewCmd() tea.Cmd {+ if len(m.registryResults) == 0 || m.registrySelected < 0 || m.registrySelected >= len(m.registryResults) {+ return nil+ }+ s := m.registryResults[m.registrySelected]+ key := s.Source + "\x00" + s.Slug+ if m.registryPreviews != nil {+ if _, exists := m.registryPreviews[key]; exists {+ return nil+ }+ }+ for _, disc := range m.discovery {+ if disc.Status == DiscoveryReady {+ for _, ds := range disc.Skills {+ if compat.NormalizeName(ds.Name) == compat.NormalizeName(s.DisplayName) || compat.NormalizeName(ds.Name) == compat.NormalizeName(s.Slug) {+ if ds.Preview != "" || ds.Description != "" {+ return nil+ }+ }+ }+ }+ }+ return m.fetchRegistryPreviewCmd(key, s.Source)+}diff --git a/internal/tui/update_test.go b/internal/tui/update_test.goindex 30c82f9..37f783b 100644--- a/internal/tui/update_test.go+++ b/internal/tui/update_test.go@@ -676,9 +676,9 @@ func TestTUIRegistryListRenderingWithContextAndFocus(t *testing.T) {if !strings.Contains(viewStr1, "My Display Name") || !strings.Contains(viewStr1, "my-org/my-repo") {t.Fatal("expected view to contain display name and source context")}- // Prefix for highlighted-only row starts with "›· "- if !strings.Contains(viewStr1, "›· My Display Name") {- t.Errorf("expected prefix '›· ' for highlighted row, got view:\n%s", viewStr1)+ // Prefix for highlighted-only row starts with ">"+ if !strings.Contains(viewStr1, ">My Display Name") {+ t.Errorf("expected prefix '>' for highlighted row, got view:\n%s", viewStr1)}// Verify parsed Repository/Folder and matched Description in Right Paneif !strings.Contains(viewStr1, "Source: my-org/my-repo") {@@ -774,3 +774,37 @@ func TestTUIRegistryModeKeySeparation(t *testing.T) {t.Errorf("expected query to remain unchanged on list-focused alpha input, got query=%q", m.registryQuery)}}++func TestTUIRegistryPreviewAndNoInstallCommands(t *testing.T) {+ m := newModel("")+ m.width = 120+ m.height = 30+ m.registryModal = true+ m.registryQuery = "xyz"+ m.registryResults = []registry.Skill{+ {DisplayName: "Test Skill", Slug: "test-skill", Source: "https://github.com/my-org/my-repo/skills/test-folder"},+ }+ m.registrySelected = 0++ // 1. Without preview fetched, it should show the derived preview context+ viewStr1 := m.View()+ if strings.Contains(viewStr1, "No preview available") {+ t.Error("expected derived preview context, but found 'No preview available'")+ }+ if !strings.Contains(viewStr1, "A lazyskills skill named 'Test Skill'") {+ t.Error("expected derived preview description to be shown")+ }++ // 2. Install Commands section must not be present in the right pane+ if strings.Contains(viewStr1, "Install Commands:") || strings.Contains(viewStr1, "Install:") || strings.Contains(viewStr1, "Local:") {+ t.Error("Install section must be completely removed from the right pane")+ }++ // 3. With HTTP raw preview fetched and cached+ key := "https://github.com/my-org/my-repo/skills/test-folder" + "\x00" + "test-skill"+ m.registryPreviews[key] = "This is a fetched SKILL.md markdown preview!"+ viewStr2 := m.View()+ if !strings.Contains(viewStr2, "This is a fetched SKILL.md markdown preview!") {+ t.Error("expected the fetched HTTP preview to be displayed")+ }+}diff --git a/internal/tui/view.go b/internal/tui/view.goindex 16c0110..0f04de4 100644--- a/internal/tui/view.go+++ b/internal/tui/view.go@@ -1814,13 +1814,13 @@ func (m appModel) registryModalOverlay(layout appLayout) string {_, isSel = m.registrySelectedKeys[s.Source+"\x00"+s.Slug]}- prefix := " "+ prefix := " "if idx == m.registrySelected && isSel {- prefix = "›● "+ prefix = ">*"} else if idx == m.registrySelected {- prefix = "›· "+ prefix = ">"} else if isSel {- prefix = " ● "+ prefix = " *"}prefixWidth := lipgloss.Width(prefix)@@ -1927,17 +1927,11 @@ func (m appModel) registryModalOverlay(layout appLayout) string {)var statusVal string- allowInstall := true- cantInstallReason := ""if status == StatusInstalled {statusVal = scopeProjectStyle.Render("[installed] Already installed")- allowInstall = false- cantInstallReason = "Already installed in project or global catalog."} else if s.Invalid {statusVal = errorStyle.Render("unavailable")- allowInstall = false- cantInstallReason = compat.FirstNonEmpty(s.Reason, "registry result cannot be safely installed")} else if status == StatusSimilarInstalled {statusVal = warningStyle.Render("[similar] Similar name installed")} else {@@ -1977,6 +1971,15 @@ func (m appModel) registryModalOverlay(layout appLayout) string {}}+ key := s.Source + "\x00" + s.Slug+ var fetchedPreview string+ if m.registryPreviews != nil {+ fetchedPreview = m.registryPreviews[key]+ }+ if matchedPreview == "" && fetchedPreview != "" {+ matchedPreview = fetchedPreview+ }+if matchedDesc != "" {rightContentLines = append(rightContentLines,"",@@ -1993,93 +1996,16 @@ func (m appModel) registryModalOverlay(layout appLayout) string {}if matchedDesc == "" && matchedPreview == "" {- rightContentLines = append(rightContentLines,- "",- sectionHeaderStyle.Render("Preview:"),- dimStyle.Render("No preview available"),- )- }-- var localCmd string- var globalCmd string-- if selectedCount > 0 {- var list []actions.AvailableSkillInstall- for _, sel := range m.registrySelectedKeys {- list = append(list, actions.AvailableSkillInstall{- Source: sel.Source,- DisplayName: sel.DisplayName,- Slug: sel.Slug,- })- }- projPreview := actions.ForAvailableSkills(list, false)- globalPreview := actions.ForAvailableSkills(list, true)-- if projPreview.Available {- localCmd = projPreview.Command- } else {- localCmd = "disabled: " + projPreview.Reason- }- if globalPreview.Available {- globalCmd = globalPreview.Command- } else {- globalCmd = "disabled: " + globalPreview.Reason- }- } else {- projActions := actions.ForAvailableSkillWithOptions(s.Source, actions.InstallOptions{- DisplayName: s.DisplayName,- Slug: s.Slug,- Global: false,- })- globalActions := actions.ForAvailableSkillWithOptions(s.Source, actions.InstallOptions{- DisplayName: s.DisplayName,- Slug: s.Slug,- Global: true,- })-- if len(projActions) == 0 {- localCmd = "disabled"- } else if !projActions[0].Available {- localCmd = "disabled: " + projActions[0].Reason- } else {- localCmd = projActions[0].Command- }-- if len(globalActions) == 0 {- globalCmd = "disabled"- } else if !globalActions[0].Available {- globalCmd = "disabled: " + globalActions[0].Reason- } else {- globalCmd = globalActions[0].Command+ // Surface metadata as description context so we don't just say No preview available+ derivedDesc := fmt.Sprintf("A lazyskills skill named '%s' (slug: '%s'), available from source '%s'.", s.DisplayName, s.Slug, repo)+ if folder != "" {+ derivedDesc += fmt.Sprintf(" Located under subfolder path '%s'.", folder)}- }-- if !allowInstall && cantInstallReason != "" {- rightContentLines = append(rightContentLines,- "",- errorStyle.Render(wrapText("Installations disabled: "+cantInstallReason, rightWidth)),- )- } else {rightContentLines = append(rightContentLines,"",- sectionHeaderStyle.Render("Install:"),+ sectionHeaderStyle.Render("Preview Context:"),+ wrapText(derivedDesc, rightWidth),)- localLines := strings.Split(wrapText(localCmd, max(1, rightWidth-10)), "\n")- for i, l := range localLines {- if i == 0 {- rightContentLines = append(rightContentLines, " Local: "+l)- } else {- rightContentLines = append(rightContentLines, " "+l)- }- }- globalLines := strings.Split(wrapText(globalCmd, max(1, rightWidth-10)), "\n")- for i, l := range globalLines {- if i == 0 {- rightContentLines = append(rightContentLines, " Global: "+l)- } else {- rightContentLines = append(rightContentLines, " "+l)- }- }}} else {rightContentLines = append(rightContentLines, dimStyle.Render("Select a registry search result to view details."))