Skip to content

mission control for agent skills

Complete v1 TUI workflows

Alvin Unreal2a0fc456e6ea
diff --git a/README.md b/README.md
index e49cb48..b8fba8d 100644
--- a/README.md
+++ b/README.md
@@ -12,12 +12,14 @@ It is designed to complement the official `skills` CLI, not replace it.
- Visibility reasons per agent, including missing links, broken symlinks, unsupported global installs, and ghost agent-directory skills
- `SKILL.md` preview with safe terminal sanitization
- Responsive panes and scrollable details
+- Source/repo group headers in the skill list
- Guarded actions:
- refresh/rescan
- open selected skill in `$EDITOR`
- reinstall/update selected skill through the official `skills` CLI
- remove selected skill through the official `skills` CLI
- bulk reinstall/update or remove marked skills
+- Source/repo-aware selection for grouped workflows
- Structured command execution with confirmation, captured output, and rescan after successful mutations
## Install / build
@@ -52,6 +54,10 @@ Common TUI keys:
| --- | --- |
| `↑/↓`, `j/k` | Move selection |
| `space` | Mark/unmark skill for bulk actions |
+| `s` | Mark all skills from the current source/repo |
+| `o` | Open current skill in `$EDITOR` |
+| `u` | Update current skill, or marked skills if any are selected |
+| `x` | Remove current skill, or marked skills if any are selected |
| `tab`, `shift+tab`, `←/→` | Change project/global scope filter |
| `a` | Cycle agent filter |
| `A` | Reset agent filter to all agents |
@@ -62,7 +68,9 @@ Common TUI keys:
| `?` | Toggle help |
| `q` | Quit |
-Mutating actions require confirmation. Single remove requires typing the exact installed directory identity. Bulk actions require typing the displayed phrase, such as `update 2 skills` or `remove 2 skills`.
+Mutating actions open a centered confirmation prompt. Press Enter for the default yes, or type `y`, `yes`, or the displayed phrase. Press `n` or Esc to cancel.
+
+The skill list groups adjacent skills by source/repo when lock metadata is available. Skill details also show the exact folder and ref. Use `s` to mark every skill from the current source/repo, then `u` or `x` to update or remove that group with confirmation.
## How actions work
diff --git a/internal/tui/tui.go b/internal/tui/tui.go
index f61c724..de84c27 100644
--- a/internal/tui/tui.go
+++ b/internal/tui/tui.go
@@ -45,6 +45,7 @@ type appModel struct {
confirmInput string
confirmError string
running bool
+ runningTitle string
actionResult *runner.Result
width int
height int
@@ -139,6 +140,7 @@ func (m appModel) Update(msg tea.Msg) (tea.Model, tea.Cmd) {
m.syncViewport()
case actionResultMsg:
m.running = false
+ m.runningTitle = ""
m.confirming = false
m.confirmInput = ""
m.actionResult = &msg.result
@@ -164,6 +166,12 @@ func (m appModel) Update(msg tea.Msg) (tea.Model, tea.Cmd) {
m.confirming = false
m.confirmInput = ""
m.confirmError = ""
+ case "n":
+ if m.confirmInput == "" {
+ m.confirming = false
+ m.confirmInput = ""
+ m.confirmError = ""
+ }
case "pgdown", "ctrl+d", "pgup", "ctrl+u":
var cmd tea.Cmd
m.viewport, cmd = m.viewport.Update(msg)
@@ -242,6 +250,16 @@ func (m appModel) Update(msg tea.Msg) (tea.Model, tea.Cmd) {
m.toggleSelectedSkill()
m.action = 0
m.actionResult = nil
+ case "s":
+ m.selectCurrentSourceGroup()
+ m.action = 0
+ m.actionResult = nil
+ case "o":
+ return m.startCurrentSkillActionByID("open_skill")
+ case "u":
+ return m.startActionByID(preferredUpdateActionID(m.selectedCount()))
+ case "x":
+ return m.startActionByID(preferredRemoveActionID(m.selectedCount()))
case "/":
m.searching = true
case "enter":
@@ -353,14 +371,59 @@ func (m appModel) startAction() (tea.Model, tea.Cmd) {
return m.executeAction(action)
}
+func (m appModel) startActionByID(id string) (tea.Model, tea.Cmd) {
+ if id == "" {
+ return m, nil
+ }
+ for i, action := range m.currentActions() {
+ if action.ID == id {
+ m.action = i
+ m.commands = false
+ return m.startAction()
+ }
+ }
+ return m, nil
+}
+
+func (m appModel) startCurrentSkillActionByID(id string) (tea.Model, tea.Cmd) {
+ items := m.filteredSkills()
+ if len(items) == 0 || m.selected >= len(items) {
+ return m, nil
+ }
+ for _, action := range actions.ForSkill(items[m.selected]) {
+ if action.ID == id {
+ if !action.Available {
+ return m, nil
+ }
+ m.commands = false
+ return m.executeAction(action)
+ }
+ }
+ return m, nil
+}
+
+func preferredUpdateActionID(selectedCount int) string {
+ if selectedCount > 0 {
+ return "bulk_reinstall_update"
+ }
+ return "reinstall_update"
+}
+
+func preferredRemoveActionID(selectedCount int) string {
+ if selectedCount > 0 {
+ return "bulk_remove"
+ }
+ return "remove"
+}
+
func (m appModel) confirmAction() (tea.Model, tea.Cmd) {
actions := m.currentActions()
if len(actions) == 0 || m.action >= len(actions) {
return m, nil
}
action := actions[m.action]
- if m.confirmInput != action.ConfirmValue {
- m.confirmError = "Confirmation did not match. Try again or press Esc to cancel."
+ if !confirmationAccepted(m.confirmInput, action.ConfirmValue) {
+ m.confirmError = "Type yes, y, or the displayed phrase. Press Esc to cancel."
m.confirmInput = ""
m.syncViewport()
return m, nil
@@ -368,6 +431,11 @@ func (m appModel) confirmAction() (tea.Model, tea.Cmd) {
return m.executeAction(action)
}
+func confirmationAccepted(input, confirmValue string) bool {
+ value := strings.TrimSpace(strings.ToLower(input))
+ return value == "" || value == "y" || value == "yes" || input == confirmValue
+}
+
func (m appModel) executeAction(action actions.CommandPreview) (tea.Model, tea.Cmd) {
if action.Exec.Internal == "refresh" {
m.actionResult = nil
@@ -377,6 +445,7 @@ func (m appModel) executeAction(action actions.CommandPreview) (tea.Model, tea.C
cmd := exec.Command(action.Exec.Program, action.Exec.Args...)
cmd.Dir = m.cwd
m.running = true
+ m.runningTitle = action.Title
m.actionResult = nil
m.confirming = false
m.confirmInput = ""
@@ -393,6 +462,7 @@ func (m appModel) executeAction(action actions.CommandPreview) (tea.Model, tea.C
}
if len(action.Exec.Batch) > 0 {
m.running = true
+ m.runningTitle = action.Title
m.actionResult = nil
m.confirming = false
m.confirmInput = ""
@@ -405,6 +475,7 @@ func (m appModel) executeAction(action actions.CommandPreview) (tea.Model, tea.C
}
spec := runner.ExecSpec{Program: action.Exec.Program, Args: action.Exec.Args, Cwd: m.cwd}
m.running = true
+ m.runningTitle = action.Title
m.actionResult = nil
m.confirming = false
m.confirmInput = ""
@@ -481,6 +552,30 @@ func (m *appModel) toggleSelectedSkill() {
}
}
+func (m *appModel) selectCurrentSourceGroup() {
+ items := m.filteredSkills()
+ if len(items) == 0 || m.selected >= len(items) {
+ return
+ }
+ currentGroup := sourceGroupKey(items[m.selected])
+ if currentGroup == "" {
+ return
+ }
+ if m.selectedKeys == nil {
+ m.selectedKeys = map[string]bool{}
+ }
+ changed := false
+ for _, skill := range items {
+ if sourceGroupKey(skill) == currentGroup {
+ m.selectedKeys[skillKey(skill)] = true
+ changed = true
+ }
+ }
+ if !changed && len(m.selectedKeys) == 0 {
+ m.selectedKeys = nil
+ }
+}
+
func (m appModel) isSelected(skill *model.Skill) bool {
return len(m.selectedKeys) > 0 && m.selectedKeys[skillKey(skill)]
}
@@ -509,6 +604,94 @@ func skillKey(skill *model.Skill) string {
return strings.Join([]string{string(skill.Scope), skill.Name, skill.CanonicalPath, skill.SkillPath}, "\x00")
}
+func sourceGroupKey(skill *model.Skill) string {
+ info := sourceInfo(skill)
+ if info.Source == "" {
+ return ""
+ }
+ return info.Source
+}
+
+func sourceGroupLabel(skill *model.Skill) string {
+ info := sourceInfo(skill)
+ if info.Source == "" {
+ return ""
+ }
+ return info.Source
+}
+
+func listGroupLabel(skill *model.Skill) string {
+ if label := sourceGroupLabel(skill); label != "" {
+ return label
+ }
+ return "No source metadata"
+}
+
+type skillSourceInfo struct {
+ Source string
+ Folder string
+ Ref string
+}
+
+func sourceInfo(skill *model.Skill) skillSourceInfo {
+ if skill == nil {
+ return skillSourceInfo{}
+ }
+ if skill.Scope == model.ScopeProject && skill.LocalLock != nil {
+ return localSourceInfo(skill.LocalLock)
+ }
+ if skill.Scope == model.ScopeGlobal && skill.GlobalLock != nil {
+ return globalSourceInfo(skill.GlobalLock)
+ }
+ if skill.LocalLock != nil {
+ return localSourceInfo(skill.LocalLock)
+ }
+ if skill.GlobalLock != nil {
+ return globalSourceInfo(skill.GlobalLock)
+ }
+ return skillSourceInfo{}
+}
+
+func localSourceInfo(lock *model.LocalLockEntry) skillSourceInfo {
+ if lock == nil {
+ return skillSourceInfo{}
+ }
+ return skillSourceInfo{Source: compat.SanitizeMetadata(lock.Source), Folder: skillFolder(lock.SkillPath), Ref: compat.SanitizeMetadata(lock.Ref)}
+}
+
+func globalSourceInfo(lock *model.GlobalLockEntry) skillSourceInfo {
+ if lock == nil {
+ return skillSourceInfo{}
+ }
+ source := lock.Source
+ if source == "" {
+ source = lock.SourceURL
+ }
+ return skillSourceInfo{Source: compat.SanitizeMetadata(source), Folder: skillFolder(lock.SkillPath), Ref: compat.SanitizeMetadata(lock.Ref)}
+}
+
+func skillFolder(skillPath string) string {
+ folder := compat.SanitizeMetadata(skillPath)
+ folder = strings.TrimSuffix(folder, "/SKILL.md")
+ folder = strings.TrimSuffix(folder, "SKILL.md")
+ return strings.Trim(folder, "/")
+}
+
+func sourceDetailLines(skill *model.Skill, width int) []string {
+ info := sourceInfo(skill)
+ if info.Source == "" {
+ return nil
+ }
+ lines := []string{wrapText("Source: "+info.Source, width)}
+ if info.Folder != "" {
+ lines = append(lines, wrapText("Folder: "+info.Folder, width))
+ }
+ if info.Ref != "" {
+ lines = append(lines, wrapText("Ref: "+info.Ref, width))
+ }
+ return lines
+}
+
func (m *appModel) pruneSelected() {
if len(m.selectedKeys) == 0 {
return
@@ -553,7 +736,14 @@ func (m appModel) View() string {
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)
- return lipgloss.JoinHorizontal(lipgloss.Top, left, list, detail) + "\n" + footer
+ view := lipgloss.JoinHorizontal(lipgloss.Top, left, list, detail) + "\n" + footer
+ if viewModel.running {
+ return viewModel.runningOverlay(layout)
+ }
+ if viewModel.confirming {
+ return viewModel.confirmationOverlay(layout)
+ }
+ return view
}
func (m appModel) filterPane(width int) string {
@@ -590,7 +780,7 @@ func (m appModel) filterPane(width int) string {
lines = append(lines, "", "Search", prompt)
}
if m.help {
- lines = append(lines, "", "Keys", "↑/↓ j/k select", "space mark", "tab scope", "a agent", "A all agents", "c actions", "enter run action", "/ search", "r refresh", "? help", "q quit")
+ lines = append(lines, "", "Keys", "↑/↓ j/k select", "space mark", "s source mark", "o open", "u update", "x remove", "tab scope", "a agent", "A all agents", "c actions", "/ search", "r refresh", "? help", "q quit")
}
return strings.Join(lines, "\n")
}
@@ -616,14 +806,16 @@ func (m appModel) listPane(height, width int) string {
return strings.Join(append(lines, "", dimStyle.Render(detail)), "\n")
}
visible := max(1, height-3)
- start := 0
- if m.selected >= visible {
- start = m.selected - visible + 1
- }
- end := min(len(items), start+visible)
- for i := start; i < end; i++ {
+ rows := []listRow{}
+ previousGroup := ""
+ selectedRow := 0
+ for i := 0; i < len(items); i++ {
skill := items[i]
view := display.Skill(skill)
+ if group := listGroupLabel(skill); group != previousGroup {
+ rows = append(rows, listRow{line: dimStyle.Render(truncate("─ "+group, width)), skillIndex: -1})
+ previousGroup = group
+ }
mark := " "
if m.isSelected(skill) {
mark = "● "
@@ -635,17 +827,35 @@ func (m appModel) listPane(height, width int) string {
if len(view.HealthIssues) > 0 {
label += fmt.Sprintf(" ⚠ %d", len(view.HealthIssues))
}
+ var line string
if i == m.selected {
- lines = append(lines, selectedStyle.Render(truncate(label, width)))
+ line = selectedStyle.Render(truncate(label, width))
} else if len(view.HealthIssues) > 0 {
- lines = append(lines, errorStyle.Render(truncate(label, width)))
+ line = errorStyle.Render(truncate(label, width))
} else {
- lines = append(lines, truncate(label, width))
+ line = truncate(label, width)
+ }
+ if i == m.selected {
+ selectedRow = len(rows)
}
+ rows = append(rows, listRow{line: line, skillIndex: i})
+ }
+ start := 0
+ if selectedRow >= visible {
+ start = selectedRow - visible + 1
+ }
+ end := min(len(rows), start+visible)
+ for _, row := range rows[start:end] {
+ lines = append(lines, row.line)
}
return strings.Join(lines, "\n")
}
+type listRow struct {
+ line string
+ skillIndex int
+}
+
func (m appModel) detailPane() string {
return m.viewport.View()
}
@@ -674,6 +884,9 @@ func (m appModel) detailLines(width int) []string {
fmt.Sprintf("Scope: %s", view.Scope),
wrapText(fmt.Sprintf("Lock: %s", display.LockSummary(view)), width),
}
+ if sourceLines := sourceDetailLines(items[m.selected], width); len(sourceLines) > 0 {
+ lines = append(lines, sourceLines...)
+ }
if view.CanonicalPath != "" {
lines = append(lines, wrapText("Canonical: "+view.CanonicalPath, width))
}
@@ -754,21 +967,12 @@ func (m appModel) commandPreview(sk *model.Skill, width int) []string {
title = fmt.Sprintf(" Bulk actions · %d selected ", count)
}
lines := []string{actionTitleStyle.Render(title)}
- lines = append(lines, dimStyle.Render(" j/k choose, enter run, c hide"))
+ lines = append(lines, dimStyle.Render(" j/k choose, enter run, o/u/x shortcuts, c hide"))
if m.running {
lines = append(lines, "", " "+runningStyle.Render("Running action..."))
}
if m.confirming {
- current := m.currentActions()
- prompt := "type confirmation"
- if len(current) > 0 && m.action < len(current) {
- prompt = fmt.Sprintf("type %q to confirm", current[m.action].ConfirmValue)
- }
- lines = append(lines, "", " "+errorStyle.Render("Confirm mutation"), " "+prompt, " "+dimStyle.Render("esc cancels"))
- if m.confirmError != "" {
- lines = append(lines, " "+errorStyle.Render(m.confirmError))
- }
- lines = append(lines, " > "+compat.SanitizeMetadata(m.confirmInput)+"_")
+ lines = append(lines, "", " "+errorStyle.Render("Confirmation pending"))
}
if m.actionResult != nil {
lines = append(lines, "")
@@ -842,6 +1046,50 @@ func (m appModel) renderActionResult(width int) []string {
return lines
}
+func (m appModel) confirmationOverlay(layout appLayout) string {
+ actions := m.currentActions()
+ title := "Confirm action"
+ phrase := ""
+ if len(actions) > 0 && m.action < len(actions) {
+ action := actions[m.action]
+ title = compat.SanitizeMetadata(action.Title)
+ phrase = compat.SanitizeMetadata(action.ConfirmValue)
+ }
+ lines := []string{
+ errorStyle.Bold(true).Render("Confirm"),
+ wrapText(title, 44),
+ "",
+ "Press Enter or y to confirm.",
+ "Type n or Esc to cancel.",
+ }
+ if phrase != "" {
+ lines = append(lines, dimStyle.Render("Also accepted: "+phrase))
+ }
+ if m.confirmError != "" {
+ lines = append(lines, "", errorStyle.Render(m.confirmError))
+ }
+ input := compat.SanitizeMetadata(m.confirmInput)
+ if input == "" {
+ input = dimStyle.Render("yes")
+ }
+ lines = append(lines, "", "> "+input+"_")
+ box := lipgloss.NewStyle().Border(lipgloss.RoundedBorder()).BorderForeground(actionBorderColor).Padding(1, 2).Width(52).Render(strings.Join(lines, "\n"))
+ return fitToScreen(lipgloss.Place(layout.Width, layout.Height, lipgloss.Center, lipgloss.Center, box), layout.Width, layout.Height)
+}
+
+func (m appModel) runningOverlay(layout appLayout) string {
+ title := compat.SanitizeMetadata(firstNonEmpty(m.runningTitle, "Running action"))
+ lines := []string{
+ runningStyle.Render("Running"),
+ wrapText(title, 44),
+ "",
+ "Working…",
+ dimStyle.Render("Press q or Ctrl+C to quit LazySkills."),
+ }
+ box := lipgloss.NewStyle().Border(lipgloss.RoundedBorder()).BorderForeground(actionBorderColor).Padding(1, 2).Width(52).Render(strings.Join(lines, "\n"))
+ return fitToScreen(lipgloss.Place(layout.Width, layout.Height, lipgloss.Center, lipgloss.Center, box), layout.Width, layout.Height)
+}
+
func (m appModel) footer() string {
mode := ""
selection := ""
@@ -878,6 +1126,19 @@ func (m appModel) filteredSkills() []*model.Skill {
}
out = append(out, sk)
}
+ sort.SliceStable(out, func(i, j int) bool {
+ leftGroup := listGroupLabel(out[i])
+ rightGroup := listGroupLabel(out[j])
+ if leftGroup != rightGroup {
+ return leftGroup < rightGroup
+ }
+ left := strings.ToLower(display.Skill(out[i]).Name)
+ right := strings.ToLower(display.Skill(out[j]).Name)
+ if left != right {
+ return left < right
+ }
+ return string(out[i].Scope) < string(out[j].Scope)
+ })
return out
}
diff --git a/internal/tui/tui_test.go b/internal/tui/tui_test.go
index 0082558..0323f4a 100644
--- a/internal/tui/tui_test.go
+++ b/internal/tui/tui_test.go
@@ -224,6 +224,66 @@ func TestActionConfirmationCancelDoesNotExecute(t *testing.T) {
}
}
+func TestConfirmationAcceptsDefaultYAndYes(t *testing.T) {
+ cases := []struct {
+ name string
+ input string
+ }{
+ {"default_enter", ""},
+ {"y", "y"},
+ {"yes", "yes"},
+ }
+ for _, tc := range cases {
+ t.Run(tc.name, func(t *testing.T) {
+ called := false
+ old := runExec
+ runExec = func(spec runner.ExecSpec) runner.Result { called = true; return runner.Result{ExitCode: 0} }
+ t.Cleanup(func() { runExec = old })
+
+ m := actionTestModel(t.TempDir())
+ m.commands = true
+ m.action = actionIndex(t, m, "Reinstall/update selected skill")
+ updated, _ := m.Update(tea.KeyMsg{Type: tea.KeyEnter})
+ m = updated.(appModel)
+ for _, r := range []rune(tc.input) {
+ updated, _ = m.Update(tea.KeyMsg{Type: tea.KeyRunes, Runes: []rune{r}})
+ m = updated.(appModel)
+ }
+ updated, cmd := m.Update(tea.KeyMsg{Type: tea.KeyEnter})
+ m = updated.(appModel)
+ if cmd == nil || !m.running {
+ t.Fatalf("expected accepted confirmation to run, input=%q running=%v cmd=%v", tc.input, m.running, cmd)
+ }
+ cmd()
+ if !called {
+ t.Fatalf("expected command execution")
+ }
+ })
+ }
+}
+
+func TestConfirmationRendersCenteredModal(t *testing.T) {
+ m := actionTestModel(t.TempDir())
+ m.commands = true
+ m.action = actionIndex(t, m, "Reinstall/update selected skill")
+ updated, _ := m.Update(tea.KeyMsg{Type: tea.KeyEnter})
+ m = updated.(appModel)
+ out := m.View()
+ if !strings.Contains(out, "Confirm") || !strings.Contains(out, "Press Enter or y to confirm") || strings.Contains(out, "Bulk actions") {
+ t.Fatalf("expected standalone confirmation modal, got %q", out)
+ }
+}
+
+func TestRunningActionRendersProgressModal(t *testing.T) {
+ m := actionTestModel(t.TempDir())
+ m.running = true
+ m.runningTitle = "Reinstall/update selected skill"
+ out := m.View()
+ if !strings.Contains(out, "Running") || !strings.Contains(out, "Reinstall/update selected skill") || !strings.Contains(out, "Working") {
+ t.Fatalf("expected running progress modal, got %q", out)
+ }
+}
+
func TestActionExecUsesProjectCwdAndPreventsDuplicateWhileRunning(t *testing.T) {
cwd := t.TempDir()
old := runExec
@@ -387,6 +447,130 @@ func TestBulkPartialFailureRescansAndKeepsSelection(t *testing.T) {
}
}
+func TestDirectUpdateHotkeyStartsCurrentOrBulkAction(t *testing.T) {
+ m := actionTestModel(t.TempDir())
+ updated, cmd := m.Update(tea.KeyMsg{Type: tea.KeyRunes, Runes: []rune{'u'}})
+ next := updated.(appModel)
+ if cmd != nil || next.commands || !next.confirming || next.currentActions()[next.action].ID != "reinstall_update" {
+ t.Fatalf("expected u to open current-skill update confirmation without actions, action=%#v confirming=%v commands=%v cmd=%v", next.currentActions()[next.action], next.confirming, next.commands, cmd)
+ }
+ m = bulkActionTestModel(t.TempDir())
+ m.selectedKeys = map[string]bool{skillKey(m.result.Skills[0]): true, skillKey(m.result.Skills[1]): true}
+ updated, cmd = m.Update(tea.KeyMsg{Type: tea.KeyRunes, Runes: []rune{'u'}})
+ next = updated.(appModel)
+ if cmd != nil || next.commands || !next.confirming || next.currentActions()[next.action].ID != "bulk_reinstall_update" {
+ t.Fatalf("expected u to open bulk update confirmation without actions, action=%#v confirming=%v commands=%v cmd=%v", next.currentActions()[next.action], next.confirming, next.commands, cmd)
+ }
+}
+
+func TestDirectRemoveHotkeyStartsStrictConfirmation(t *testing.T) {
+ m := actionTestModel(t.TempDir())
+ updated, cmd := m.Update(tea.KeyMsg{Type: tea.KeyRunes, Runes: []rune{'x'}})
+ next := updated.(appModel)
+ if cmd != nil || next.commands || !next.confirming || next.currentActions()[next.action].ID != "remove" || next.currentActions()[next.action].ConfirmValue != "deploy-skill" {
+ t.Fatalf("expected x to open single remove confirmation without actions, action=%#v confirming=%v commands=%v cmd=%v", next.currentActions()[next.action], next.confirming, next.commands, cmd)
+ }
+}
+
+func TestDirectOpenHotkeyUsesCurrentSkillEvenWithBulkSelection(t *testing.T) {
+ t.Setenv("EDITOR", "vim")
+ m := bulkActionTestModel(t.TempDir())
+ m.result.Skills[0].SkillPath = "/tmp/one/SKILL.md"
+ m.selectedKeys = map[string]bool{skillKey(m.result.Skills[1]): true}
+ updated, cmd := m.Update(tea.KeyMsg{Type: tea.KeyRunes, Runes: []rune{'o'}})
+ next := updated.(appModel)
+ if cmd == nil || !next.running || next.commands {
+ t.Fatalf("expected o to start interactive open without opening actions, running=%v commands=%v cmd=%v", next.running, next.commands, cmd)
+ }
+}
+
+func TestDirectOpenHotkeyClosesExistingActionMode(t *testing.T) {
+ t.Setenv("EDITOR", "vim")
+ m := actionTestModel(t.TempDir())
+ m.result.Skills[0].SkillPath = "/tmp/deploy-skill/SKILL.md"
+ m.commands = true
+ updated, cmd := m.Update(tea.KeyMsg{Type: tea.KeyRunes, Runes: []rune{'o'}})
+ next := updated.(appModel)
+ if cmd == nil || !next.running || next.commands {
+ t.Fatalf("expected o to close action mode before opening editor, running=%v commands=%v cmd=%v", next.running, next.commands, cmd)
+ }
+}
+
+func TestSourceMarkSelectsCurrentSource(t *testing.T) {
+ m := appModel{width: 120, height: 32, selected: 1, result: model.ScanResult{Skills: []*model.Skill{
+ {Name: "One", Scope: model.ScopeProject, CanonicalPath: "/tmp/one", LocalLock: &model.LocalLockEntry{Source: "owner/repo", SkillPath: "skills/web/SKILL.md"}},
+ {Name: "Two", Scope: model.ScopeProject, CanonicalPath: "/tmp/two", LocalLock: &model.LocalLockEntry{Source: "owner/repo", SkillPath: "skills/web/SKILL.md"}},
+ {Name: "Other", Scope: model.ScopeProject, CanonicalPath: "/tmp/other", LocalLock: &model.LocalLockEntry{Source: "owner/repo", SkillPath: "skills/data/SKILL.md"}},
+ {Name: "Global", Scope: model.ScopeGlobal, CanonicalPath: "/tmp/global", GlobalLock: &model.GlobalLockEntry{Source: "owner/repo"}},
+ {Name: "Different", Scope: model.ScopeProject, CanonicalPath: "/tmp/different", LocalLock: &model.LocalLockEntry{Source: "other/repo", SkillPath: "skills/web/SKILL.md"}},
+ }}}
+ updated, _ := m.Update(tea.KeyMsg{Type: tea.KeyRunes, Runes: []rune{'s'}})
+ next := updated.(appModel)
+ if next.selectedCount() != 4 || !next.isSelected(next.result.Skills[0]) || !next.isSelected(next.result.Skills[1]) || !next.isSelected(next.result.Skills[2]) || !next.isSelected(next.result.Skills[3]) || next.isSelected(next.result.Skills[4]) {
+ t.Fatalf("expected source mark to select all skills from owner/repo only, selected=%#v", next.selectedKeys)
+ }
+}
+
+func TestSourceMarkOnlySelectsFilteredSkills(t *testing.T) {
+ m := appModel{width: 120, height: 32, search: "one", result: model.ScanResult{Skills: []*model.Skill{
+ {Name: "One", Scope: model.ScopeProject, CanonicalPath: "/tmp/one", LocalLock: &model.LocalLockEntry{Source: "owner/repo"}},
+ {Name: "Two", Scope: model.ScopeProject, CanonicalPath: "/tmp/two", LocalLock: &model.LocalLockEntry{Source: "owner/repo"}},
+ }}}
+ updated, _ := m.Update(tea.KeyMsg{Type: tea.KeyRunes, Runes: []rune{'s'}})
+ next := updated.(appModel)
+ if next.selectedCount() != 1 || !next.isSelected(next.result.Skills[0]) || next.isSelected(next.result.Skills[1]) {
+ t.Fatalf("expected source mark to select only visible filtered skills, selected=%#v", next.selectedKeys)
+ }
+}
+
+func TestSourceAndFolderDetailsRender(t *testing.T) {
+ m := appModel{width: 120, height: 32, result: model.ScanResult{Skills: []*model.Skill{{
+ Name: "One", Scope: model.ScopeProject, LocalLock: &model.LocalLockEntry{Source: "owner/repo", SkillPath: "skills/web/SKILL.md", Ref: "main"},
+ }}}}
+ out := m.View()
+ if !strings.Contains(out, "Source: owner/repo") || !strings.Contains(out, "Folder: skills/web") || !strings.Contains(out, "Ref: main") {
+ t.Fatalf("expected source/folder/ref details, got %q", out)
+ }
+}
+
+func TestSkillListShowsSourceGroups(t *testing.T) {
+ m := appModel{width: 120, height: 32, result: model.ScanResult{Skills: []*model.Skill{
+ {Name: "One", Scope: model.ScopeProject, LocalLock: &model.LocalLockEntry{Source: "owner/repo", SkillPath: "skills/web/SKILL.md"}},
+ {Name: "Two", Scope: model.ScopeProject, LocalLock: &model.LocalLockEntry{Source: "owner/repo", SkillPath: "skills/web/SKILL.md"}},
+ {Name: "Other", Scope: model.ScopeProject, LocalLock: &model.LocalLockEntry{Source: "owner/repo", SkillPath: "skills/data/SKILL.md"}},
+ }}}
+ out := m.View()
+ if !strings.Contains(out, "owner/repo") {
+ t.Fatalf("expected source group header, got %q", out)
+ }
+ if strings.Count(out, "─ owner/repo") != 1 || strings.Contains(out, "owner/repo / skills/web") || strings.Contains(out, "owner/repo / skills/data") {
+ t.Fatalf("expected one repo-level group header, got %q", out)
+ }
+}
+
+func TestSkillListSeparatesNoSourceMetadata(t *testing.T) {
+ m := appModel{width: 120, height: 32, result: model.ScanResult{Skills: []*model.Skill{
+ {Name: "Tracked", Scope: model.ScopeProject, LocalLock: &model.LocalLockEntry{Source: "owner/repo"}},
+ {Name: "Manual", Scope: model.ScopeProject},
+ }}}
+ out := m.View()
+ if !strings.Contains(out, "─ owner/repo") || !strings.Contains(out, "─ No source metadata") {
+ t.Fatalf("expected explicit source and no-source groups, got %q", out)
+ }
+}
+
+func TestGroupedListKeepsSelectedRowVisible(t *testing.T) {
+ skills := []*model.Skill{}
+ for i := 0; i < 12; i++ {
+ skills = append(skills, &model.Skill{Name: fmt.Sprintf("Skill %02d", i), Scope: model.ScopeProject, LocalLock: &model.LocalLockEntry{Source: fmt.Sprintf("owner/repo-%02d", i)}})
+ }
+ m := appModel{width: 120, height: 10, selected: 11, result: model.ScanResult{Skills: skills}}
+ out := m.View()
+ if !strings.Contains(out, "Skill 11 [project]") {
+ t.Fatalf("expected selected row visible with many group headers, got %q", out)
+ }
+}
+
func TestFailedMutationDoesNotTriggerRescan(t *testing.T) {
cwd := t.TempDir()
old := runExec
@@ -429,7 +613,7 @@ func TestRemoveRequiresExactTypedIdentity(t *testing.T) {
}
updated, cmd := m.Update(tea.KeyMsg{Type: tea.KeyEnter})
m = updated.(appModel)
- if cmd != nil || !m.confirming || !strings.Contains(m.confirmError, "Confirmation did not match") || m.actionResult != nil {
+ if cmd != nil || !m.confirming || !strings.Contains(m.confirmError, "Type yes") || m.actionResult != nil {
t.Fatalf("expected inline confirmation error without command, confirming=%v err=%q result=%#v cmd=%v", m.confirming, m.confirmError, m.actionResult, cmd)
}
}