Skip to content

mission control for agent skills

Add bulk skill actions

Alvin Unrealfa64ccaddd2e
diff --git a/.gitignore b/.gitignore
index b8a41a6..eb26219 100644
--- a/.gitignore
+++ b/.gitignore
@@ -3,3 +3,4 @@
# END oh-my-opencode-slim clonedeps
.slim/deepwork/
+.codegraph/
diff --git a/README.md b/README.md
index 2b041d7..e49cb48 100644
--- a/README.md
+++ b/README.md
@@ -17,6 +17,7 @@ It is designed to complement the official `skills` CLI, not replace it.
- 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
- Structured command execution with confirmation, captured output, and rescan after successful mutations
## Install / build
@@ -50,8 +51,10 @@ Common TUI keys:
| Key | Action |
| --- | --- |
| `↑/↓`, `j/k` | Move selection |
+| `space` | Mark/unmark skill for bulk actions |
| `tab`, `shift+tab`, `←/→` | Change project/global scope filter |
| `a` | Cycle agent filter |
+| `A` | Reset agent filter to all agents |
| `/` | Search skills |
| `c` | Show guarded actions |
| `enter` | Run selected action when actions are visible |
@@ -59,7 +62,7 @@ Common TUI keys:
| `?` | Toggle help |
| `q` | Quit |
-Mutating actions require confirmation. Remove requires typing the exact installed directory identity.
+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`.
## How actions work
@@ -79,7 +82,6 @@ The registry is manually ported for now. A generated parity check is a planned f
## Safety and limitations
- LazySkills does not reimplement remote clone/install/update/remove logic in Go.
-- Bulk mutations are not implemented.
- Search/marketplace flows are not implemented.
- `skills use` integration is not implemented.
- Agent cycling is functional but not yet a searchable picker.
diff --git a/internal/actions/actions.go b/internal/actions/actions.go
index 0428ed9..e5792cb 100644
--- a/internal/actions/actions.go
+++ b/internal/actions/actions.go
@@ -1,6 +1,7 @@
package actions
import (
+ "fmt"
"os"
"os/exec"
"path/filepath"
@@ -29,6 +30,7 @@ type CommandPreview struct {
type ExecSpec struct {
Program string
Args []string
+ Batch []ExecSpec
Cwd string
Interactive bool
Internal string
@@ -40,6 +42,56 @@ func ForSkill(sk *model.Skill) []CommandPreview {
return ForSkillWithResolver(sk, ResolveSkillsCommand)
}
+func ForSkills(skills []*model.Skill) []CommandPreview {
+ return ForSkillsWithResolver(skills, ResolveSkillsCommand)
+}
+
+func ForSkillsWithResolver(skills []*model.Skill, resolve SkillsResolver) []CommandPreview {
+ if len(skills) == 0 {
+ return nil
+ }
+ if resolve == nil {
+ resolve = ResolveSkillsCommand
+ }
+ count := len(skills)
+ updateBatch, updateOK, updateReason := bulkBatch(skills, resolve, "reinstall_update")
+ removeBatch, removeOK, removeReason := bulkBatch(skills, resolve, "remove")
+ previews := []CommandPreview{}
+ if updateOK {
+ previews = append(previews, newBatchPreview("bulk_reinstall_update", fmt.Sprintf("Reinstall/update %d selected skills", count), updateBatch, fmt.Sprintf("Run the official skills CLI update flow for %d selected skills.", count), fmt.Sprintf("update %d skills", count), false))
+ } else {
+ previews = append(previews, unavailablePreview(fmt.Sprintf("Reinstall/update %d selected skills", count), updateReason))
+ }
+ if removeOK {
+ previews = append(previews, newBatchPreview("bulk_remove", fmt.Sprintf("Remove %d selected skills", count), removeBatch, fmt.Sprintf("Remove %d selected installed skills via the official skills CLI.", count), fmt.Sprintf("remove %d skills", count), true))
+ } else {
+ previews = append(previews, unavailablePreview(fmt.Sprintf("Remove %d selected skills", count), removeReason))
+ }
+ return previews
+}
+
+func bulkBatch(skills []*model.Skill, resolve SkillsResolver, actionID string) ([]ExecSpec, bool, string) {
+ batch := make([]ExecSpec, 0, len(skills))
+ for _, skill := range skills {
+ found := false
+ for _, preview := range ForSkillWithResolver(skill, resolve) {
+ if preview.ID != actionID {
+ continue
+ }
+ if !preview.Available {
+ return nil, false, fmt.Sprintf("%s: %s", compat.SanitizeMetadata(skill.Name), preview.Reason)
+ }
+ batch = append(batch, preview.Exec)
+ found = true
+ break
+ }
+ if !found {
+ return nil, false, fmt.Sprintf("%s: action unavailable", compat.SanitizeMetadata(skill.Name))
+ }
+ }
+ return batch, true, ""
+}
+
func ForSkillWithResolver(sk *model.Skill, resolve SkillsResolver) []CommandPreview {
if sk == nil {
return nil
@@ -135,6 +187,20 @@ func newPreview(id, title, program string, args []string, description string, mu
return preview
}
+func newBatchPreview(id, title string, batch []ExecSpec, description, confirmValue string, dangerous bool) CommandPreview {
+ if len(batch) == 0 {
+ return unavailablePreview(title, "no executable commands")
+ }
+ commands := make([]string, 0, len(batch))
+ for _, spec := range batch {
+ if spec.Program == "" || len(spec.Args) == 0 || spec.Interactive || spec.Internal != "" {
+ return unavailablePreview(title, "bulk action contains unsupported command")
+ }
+ commands = append(commands, renderCommand(spec.Program, spec.Args))
+ }
+ return CommandPreview{ID: id, Title: title, Exec: ExecSpec{Batch: batch}, Command: strings.Join(commands, " && "), Description: description, Mutates: true, RequiresConfirm: true, Dangerous: dangerous, ConfirmValue: confirmValue, Available: true}
+}
+
func unavailablePreview(title, reason string) CommandPreview {
return CommandPreview{Title: title, Available: false, Reason: compat.SanitizeMetadata(firstNonEmpty(reason, "not enough safe identity data to build this command"))}
}
diff --git a/internal/actions/actions_test.go b/internal/actions/actions_test.go
index cbd63dd..136beb0 100644
--- a/internal/actions/actions_test.go
+++ b/internal/actions/actions_test.go
@@ -39,6 +39,23 @@ func TestForSkillBuildsStructuredSanitizedCommandPreviews(t *testing.T) {
}
}
+func TestBulkActionsBuildBatchCommands(t *testing.T) {
+ 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"}},
+ }
+ previews := ForSkillsWithResolver(skills, func() (string, []string) { return "skills", nil })
+ if len(previews) != 2 {
+ t.Fatalf("expected update and remove bulk actions, got %#v", previews)
+ }
+ if previews[0].ConfirmValue != "update 2 skills" || len(previews[0].Exec.Batch) != 2 {
+ t.Fatalf("unexpected bulk update preview: %#v", previews[0])
+ }
+ if previews[1].ConfirmValue != "remove 2 skills" || !previews[1].Dangerous || len(previews[1].Exec.Batch) != 2 {
+ t.Fatalf("unexpected bulk remove preview: %#v", previews[1])
+ }
+}
+
func TestOpenEditorActionUsesSafeEditorAndSkillPath(t *testing.T) {
t.Setenv("EDITOR", "vim -n")
previews := ForSkill(&model.Skill{Name: "Deploy", Scope: model.ScopeProject, SkillPath: "/tmp/deploy/SKILL.md"})
diff --git a/internal/tui/tui.go b/internal/tui/tui.go
index fbc8f77..f61c724 100644
--- a/internal/tui/tui.go
+++ b/internal/tui/tui.go
@@ -38,6 +38,7 @@ type appModel struct {
search string
searching bool
commands bool
+ selectedKeys map[string]bool
help bool
action int
confirming bool
@@ -97,8 +98,9 @@ type snapshotMsg struct {
}
type actionResultMsg struct {
- result runner.Result
- mutates bool
+ result runner.Result
+ mutates bool
+ partialSuccess bool
}
func Run(cwd string) error {
@@ -132,6 +134,7 @@ func (m appModel) Update(msg tea.Msg) (tea.Model, tea.Cmd) {
m.result = msg.result
m.err = msg.err
m.clampSelection()
+ m.pruneSelected()
m.actionResult = nil
m.syncViewport()
case actionResultMsg:
@@ -139,8 +142,12 @@ func (m appModel) Update(msg tea.Msg) (tea.Model, tea.Cmd) {
m.confirming = false
m.confirmInput = ""
m.actionResult = &msg.result
+ succeeded := msg.result.ExitCode == 0 && msg.result.Err == ""
+ if msg.mutates && succeeded {
+ m.selectedKeys = nil
+ }
m.syncViewport()
- if msg.mutates && msg.result.ExitCode == 0 && msg.result.Err == "" {
+ if msg.mutates && (succeeded || msg.partialSuccess) {
return m, loadSnapshot(m.cwd)
}
case tea.KeyMsg:
@@ -211,7 +218,11 @@ func (m appModel) Update(msg tea.Msg) (tea.Model, tea.Cmd) {
switch key {
case "esc":
- if m.commands {
+ if m.selectedCount() > 0 {
+ m.selectedKeys = nil
+ m.action = 0
+ m.actionResult = nil
+ } else if m.commands {
m.commands = false
} else if m.agent != "" {
m.agent = ""
@@ -227,6 +238,10 @@ func (m appModel) Update(msg tea.Msg) (tea.Model, tea.Cmd) {
case "c":
m.commands = !m.commands
m.action = 0
+ case " ":
+ m.toggleSelectedSkill()
+ m.action = 0
+ m.actionResult = nil
case "/":
m.searching = true
case "enter":
@@ -307,6 +322,10 @@ func (m *appModel) clampAction() {
}
func (m appModel) currentActions() []actions.CommandPreview {
+ selected := m.selectedSkills()
+ if len(selected) > 0 {
+ return actions.ForSkills(selected)
+ }
items := m.filteredSkills()
if len(items) == 0 || m.selected >= len(items) {
return nil
@@ -372,6 +391,18 @@ func (m appModel) executeAction(action actions.CommandPreview) (tea.Model, tea.C
return actionResultMsg{result: result, mutates: action.Mutates}
})
}
+ if len(action.Exec.Batch) > 0 {
+ m.running = true
+ m.actionResult = nil
+ m.confirming = false
+ m.confirmInput = ""
+ m.confirmError = ""
+ m.syncViewport()
+ return m, func() tea.Msg {
+ result, partialSuccess := m.runBatch(action.Exec.Batch)
+ return actionResultMsg{result: result, mutates: action.Mutates, partialSuccess: partialSuccess}
+ }
+ }
spec := runner.ExecSpec{Program: action.Exec.Program, Args: action.Exec.Args, Cwd: m.cwd}
m.running = true
m.actionResult = nil
@@ -385,6 +416,23 @@ func (m appModel) executeAction(action actions.CommandPreview) (tea.Model, tea.C
}
}
+func (m appModel) runBatch(batch []actions.ExecSpec) (runner.Result, bool) {
+ lines := []string{}
+ succeeded := 0
+ for i, spec := range batch {
+ runSpec := runner.ExecSpec{Program: spec.Program, Args: spec.Args, Cwd: m.cwd}
+ result := runExec(runSpec)
+ prefix := fmt.Sprintf("%d/%d %s", i+1, len(batch), compat.SanitizeMetadata(spec.Program))
+ if result.ExitCode != 0 || result.Err != "" {
+ result.Stdout = strings.Join(append(lines, prefix+" failed"), "\n")
+ return result, succeeded > 0
+ }
+ succeeded++
+ lines = append(lines, prefix+" ok")
+ }
+ return runner.Result{Program: "bulk", Cwd: m.cwd, ExitCode: 0, Stdout: strings.Join(lines, "\n")}, false
+}
+
func (m *appModel) syncViewport() {
layout := newAppLayout(m.width, m.height)
if layout.Small {
@@ -414,6 +462,71 @@ func (m *appModel) clampSelection() {
}
}
+func (m *appModel) toggleSelectedSkill() {
+ items := m.filteredSkills()
+ if len(items) == 0 || m.selected >= len(items) {
+ return
+ }
+ if m.selectedKeys == nil {
+ m.selectedKeys = map[string]bool{}
+ }
+ key := skillKey(items[m.selected])
+ if m.selectedKeys[key] {
+ delete(m.selectedKeys, key)
+ } else {
+ m.selectedKeys[key] = true
+ }
+ if len(m.selectedKeys) == 0 {
+ m.selectedKeys = nil
+ }
+}
+
+func (m appModel) isSelected(skill *model.Skill) bool {
+ return len(m.selectedKeys) > 0 && m.selectedKeys[skillKey(skill)]
+}
+
+func (m appModel) selectedCount() int {
+ return len(m.selectedKeys)
+}
+
+func (m appModel) selectedSkills() []*model.Skill {
+ if len(m.selectedKeys) == 0 {
+ return nil
+ }
+ selected := make([]*model.Skill, 0, len(m.selectedKeys))
+ for _, skill := range m.result.Skills {
+ if m.isSelected(skill) {
+ selected = append(selected, skill)
+ }
+ }
+ return selected
+}
+
+func skillKey(skill *model.Skill) string {
+ if skill == nil {
+ return ""
+ }
+ return strings.Join([]string{string(skill.Scope), skill.Name, skill.CanonicalPath, skill.SkillPath}, "\x00")
+}
+
+func (m *appModel) pruneSelected() {
+ if len(m.selectedKeys) == 0 {
+ return
+ }
+ valid := map[string]bool{}
+ for _, skill := range m.result.Skills {
+ valid[skillKey(skill)] = true
+ }
+ for key := range m.selectedKeys {
+ if !valid[key] {
+ delete(m.selectedKeys, key)
+ }
+ }
+ if len(m.selectedKeys) == 0 {
+ m.selectedKeys = nil
+ }
+}
+
func (m appModel) View() string {
if m.err != nil {
return fitToScreen(errorStyle.Render(fmt.Sprintf("LazySkills error: %s\n\nPress q to quit.", compat.SanitizeMetadata(m.err.Error()))), viewWidth(m.width), viewHeight(m.height))
@@ -477,7 +590,7 @@ func (m appModel) filterPane(width int) string {
lines = append(lines, "", "Search", prompt)
}
if m.help {
- lines = append(lines, "", "Keys", "↑/↓ j/k select", "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", "tab scope", "a agent", "A all agents", "c actions", "enter run action", "/ search", "r refresh", "? help", "q quit")
}
return strings.Join(lines, "\n")
}
@@ -509,8 +622,13 @@ func (m appModel) listPane(height, width int) string {
}
end := min(len(items), start+visible)
for i := start; i < end; i++ {
- view := display.Skill(items[i])
- label := fmt.Sprintf("%s [%s]", view.Name, view.Scope)
+ skill := items[i]
+ view := display.Skill(skill)
+ mark := " "
+ if m.isSelected(skill) {
+ mark = "● "
+ }
+ label := fmt.Sprintf("%s%s [%s]", mark, view.Name, view.Scope)
if m.agent != "" {
label += " " + agentVisibilityBadge(items[i], m.agent)
}
@@ -539,7 +657,14 @@ func (m appModel) detailText(width int) string {
func (m appModel) detailLines(width int) []string {
items := m.filteredSkills()
if len(items) == 0 {
- return []string{titleStyle.Render("Details"), "", dimStyle.Render("Select a skill to inspect it.")}
+ lines := []string{titleStyle.Render("Details"), "", dimStyle.Render("Select a skill to inspect it.")}
+ if m.commands && m.selectedCount() > 0 {
+ lines = append(lines, "")
+ divider := lipgloss.NewStyle().Foreground(lipgloss.Color("62")).Render(strings.Repeat("─", max(1, width)))
+ lines = append(lines, divider)
+ lines = append(lines, m.commandPreview(nil, max(1, width-4))...)
+ }
+ return lines
}
view := display.Skill(items[m.selected])
lines := []string{
@@ -624,7 +749,11 @@ func (m appModel) visibilitySummary(view display.SkillView) []string {
}
func (m appModel) commandPreview(sk *model.Skill, width int) []string {
- lines := []string{actionTitleStyle.Render(" Actions ")}
+ title := " Actions "
+ if count := m.selectedCount(); count > 0 {
+ 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"))
if m.running {
lines = append(lines, "", " "+runningStyle.Render("Running action..."))
@@ -715,12 +844,16 @@ func (m appModel) renderActionResult(width int) []string {
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 hide"
}
- return dimStyle.Render("LazySkills "+appVersion) + mode
+ return dimStyle.Render("LazySkills "+appVersion) + selection + mode
}
func (m appModel) filteredSkills() []*model.Skill {
diff --git a/internal/tui/tui_test.go b/internal/tui/tui_test.go
index d6c9240..0082558 100644
--- a/internal/tui/tui_test.go
+++ b/internal/tui/tui_test.go
@@ -175,7 +175,7 @@ func TestAgentFilterListMarksNonVisibleSkills(t *testing.T) {
},
}}}
out := m.View()
- if !strings.Contains(out, "Visible [project] ✓ visible") || !strings.Contains(out, "Missing [project] × missing_agent_l") {
+ if !strings.Contains(out, "Visible [project] ✓ visible") || !strings.Contains(out, "Missing [project] × missing_agent") {
t.Fatalf("expected list-level visibility badges, got %q", out)
}
}
@@ -261,6 +261,132 @@ func TestActionExecUsesProjectCwdAndPreventsDuplicateWhileRunning(t *testing.T)
}
}
+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") {
+ t.Fatalf("expected one marked skill, count=%d view=%q", m.selectedCount(), m.View())
+ }
+ updated, _ = m.Update(tea.KeyMsg{Type: tea.KeyEsc})
+ m = updated.(appModel)
+ if m.selectedCount() != 0 {
+ t.Fatalf("expected esc to clear selection, got %d", m.selectedCount())
+ }
+}
+
+func TestEscClearsSelectionBeforeLeavingActionModeOrAgentFilter(t *testing.T) {
+ m := bulkActionTestModel(t.TempDir())
+ m.commands = true
+ m.agent = "opencode"
+ m.selectedKeys = map[string]bool{skillKey(m.result.Skills[0]): true}
+ updated, _ := m.Update(tea.KeyMsg{Type: tea.KeyEsc})
+ next := updated.(appModel)
+ if next.selectedCount() != 0 || !next.commands || next.agent != "opencode" {
+ t.Fatalf("expected esc to clear selection first, selected=%d commands=%v agent=%q", next.selectedCount(), next.commands, next.agent)
+ }
+}
+
+func TestBulkActionsRenderAndExecuteSequentially(t *testing.T) {
+ cwd := t.TempDir()
+ calls := 0
+ old := runExec
+ runExec = func(spec runner.ExecSpec) runner.Result {
+ calls++
+ return runner.Result{Program: spec.Program, Args: spec.Args, Cwd: spec.Cwd, ExitCode: 0}
+ }
+ t.Cleanup(func() { runExec = old })
+
+ m := bulkActionTestModel(cwd)
+ m.selectedKeys = map[string]bool{}
+ for _, skill := range m.result.Skills {
+ m.selectedKeys[skillKey(skill)] = true
+ }
+ m.commands = true
+ out := m.View()
+ if !strings.Contains(out, "Bulk actions") || !strings.Contains(out, "Reinstall/update 2 selected skills") || strings.Contains(out, "Open selected skill") {
+ t.Fatalf("expected constrained bulk actions, got %q", out)
+ }
+ updated, _ := m.Update(tea.KeyMsg{Type: tea.KeyEnter})
+ m = updated.(appModel)
+ for _, r := range []rune("update 2 skills") {
+ 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 bulk command to run")
+ }
+ updated, rescan := m.Update(cmd())
+ m = updated.(appModel)
+ if calls != 2 || m.selectedCount() != 0 || rescan == nil {
+ t.Fatalf("expected two commands, cleared selection, and rescan; calls=%d selected=%d rescan=%v", calls, m.selectedCount(), rescan)
+ }
+}
+
+func TestBulkActionStopsOnFirstFailure(t *testing.T) {
+ cwd := t.TempDir()
+ calls := 0
+ old := runExec
+ runExec = func(spec runner.ExecSpec) runner.Result {
+ calls++
+ if calls == 1 {
+ return runner.Result{Program: spec.Program, Args: spec.Args, Cwd: spec.Cwd, ExitCode: 2, Stderr: "nope"}
+ }
+ return runner.Result{Program: spec.Program, Args: spec.Args, Cwd: spec.Cwd, ExitCode: 0}
+ }
+ t.Cleanup(func() { runExec = old })
+ m := bulkActionTestModel(cwd)
+ m.selectedKeys = map[string]bool{}
+ for _, skill := range m.result.Skills {
+ m.selectedKeys[skillKey(skill)] = true
+ }
+ result, partialSuccess := m.runBatch(m.currentActions()[0].Exec.Batch)
+ if calls != 1 || result.ExitCode != 2 {
+ t.Fatalf("expected stop on first failure, calls=%d result=%#v", calls, result)
+ }
+ if partialSuccess {
+ t.Fatalf("first-command failure should not count as partial success")
+ }
+}
+
+func TestBulkPartialFailureRescansAndKeepsSelection(t *testing.T) {
+ cwd := t.TempDir()
+ calls := 0
+ old := runExec
+ runExec = func(spec runner.ExecSpec) runner.Result {
+ calls++
+ if calls == 2 {
+ return runner.Result{Program: spec.Program, Args: spec.Args, Cwd: spec.Cwd, ExitCode: 2, Stderr: "nope"}
+ }
+ return runner.Result{Program: spec.Program, Args: spec.Args, Cwd: spec.Cwd, ExitCode: 0}
+ }
+ t.Cleanup(func() { runExec = old })
+ m := bulkActionTestModel(cwd)
+ m.selectedKeys = map[string]bool{}
+ for _, skill := range m.result.Skills {
+ m.selectedKeys[skillKey(skill)] = true
+ }
+ m.commands = true
+ updated, _ := m.Update(tea.KeyMsg{Type: tea.KeyEnter})
+ m = updated.(appModel)
+ for _, r := range []rune("update 2 skills") {
+ 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 {
+ t.Fatalf("expected bulk command")
+ }
+ updated, rescan := m.Update(cmd())
+ m = updated.(appModel)
+ if calls != 2 || rescan == nil || m.selectedCount() != 2 || m.actionResult == nil || m.actionResult.ExitCode != 2 {
+ t.Fatalf("expected partial failure to rescan and keep selection; calls=%d rescan=%v selected=%d result=%#v", calls, rescan, m.selectedCount(), m.actionResult)
+ }
+}
+
func TestFailedMutationDoesNotTriggerRescan(t *testing.T) {
cwd := t.TempDir()
old := runExec
@@ -318,6 +444,13 @@ func actionTestModel(cwd string) appModel {
}}}}
}
+func bulkActionTestModel(cwd string) appModel {
+ return appModel{cwd: cwd, width: 120, height: 32, result: model.ScanResult{Skills: []*model.Skill{
+ {Name: "One", Description: "desc", Scope: model.ScopeProject, CanonicalPath: "/tmp/one", LocalLock: &model.LocalLockEntry{Source: "owner/repo"}},
+ {Name: "Two", Description: "desc", Scope: model.ScopeProject, CanonicalPath: "/tmp/two", LocalLock: &model.LocalLockEntry{Source: "owner/repo"}},
+ }}}
+}
+
func actionIndex(t *testing.T, m appModel, title string) int {
t.Helper()
for i, action := range m.currentActions() {