Skip to content

mission control for agent skills

fix(tui,selfupdate): require yes for destructive confirmations

Alvin Unreal8742859380e5
diff --git a/cmd/lazyskills/main_test.go b/cmd/lazyskills/main_test.go
index de9c830..08a13d0 100644
--- a/cmd/lazyskills/main_test.go
+++ b/cmd/lazyskills/main_test.go
@@ -83,7 +83,9 @@ func TestCLIUpdate(t *testing.T) {
}
// Default channel should be "manual" on unix, or "windows" on windows.
// Since we mock it, we just check if it returns one of the guidance/command values.
- if !strings.Contains(out, "lazyskills update") && !strings.Contains(out, "To upgrade, please download") {
+ if !strings.Contains(out, "lazyskills update") &&
+ !strings.Contains(out, "To upgrade, please download") &&
+ !strings.Contains(out, "Please download the release manually") {
t.Errorf("expected command preview or download guidance, got: %q", out)
}
diff --git a/internal/selfupdate/selfupdate.go b/internal/selfupdate/selfupdate.go
index 2064761..532ff62 100644
--- a/internal/selfupdate/selfupdate.go
+++ b/internal/selfupdate/selfupdate.go
@@ -302,6 +302,16 @@ func isManualInstallSafe(path string) bool {
if strings.HasPrefix(path, "/usr/local/bin/") || strings.HasPrefix(path, "/usr/local/sbin/") {
return true
}
+ tempDir := filepath.Clean(filepath.ToSlash(os.TempDir()))
+ if strings.HasPrefix(path, tempDir+"/") {
+ return true
+ }
+ if evalTempDir, err := filepath.EvalSymlinks(os.TempDir()); err == nil {
+ evalTempDir = filepath.Clean(filepath.ToSlash(evalTempDir))
+ if strings.HasPrefix(path, evalTempDir+"/") {
+ return true
+ }
+ }
if strings.HasPrefix(path, "/tmp/") {
return true
}
diff --git a/internal/selfupdate/selfupdate_test.go b/internal/selfupdate/selfupdate_test.go
index 003ffc2..8d062a2 100644
--- a/internal/selfupdate/selfupdate_test.go
+++ b/internal/selfupdate/selfupdate_test.go
@@ -10,6 +10,7 @@ import (
"fmt"
"os"
"path/filepath"
+ "runtime"
"strings"
"testing"
"time"
@@ -254,9 +255,12 @@ func TestApplyAndChecksumMismatch(t *testing.T) {
mockRel := &GitHubRelease{
TagName: "v1.1.0",
}
- // We will determine our asset based on runtime OS/Arch
- osName := "Linux"
- archName := "x86_64"
+ // Match Apply's runtime-specific release asset naming.
+ osName := strings.Title(runtime.GOOS)
+ archName := runtime.GOARCH
+ if archName == "amd64" {
+ archName = "x86_64"
+ }
mockRel.Assets = append(mockRel.Assets, struct {
Name string `json:"name"`
BrowserDownloadURL string `json:"browser_download_url"`
diff --git a/internal/tui/tui_test.go b/internal/tui/tui_test.go
index 4c2e559..f6b900e 100644
--- a/internal/tui/tui_test.go
+++ b/internal/tui/tui_test.go
@@ -1345,11 +1345,28 @@ func TestSingleRemoveRequiresYesConfirmation(t *testing.T) {
}
updated, cmd := m.Update(tea.KeyMsg{Type: tea.KeyEnter})
m = updated.(appModel)
- if cmd != nil || !m.confirming || !strings.Contains(m.confirmError, "Type y or yes") || 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)
}
}
+func TestSingleRemoveRejectsSkillNameConfirmation(t *testing.T) {
+ m := actionTestModel(t.TempDir())
+ m.commands = true
+ m.action = actionIndex(t, m, "Remove selected skill")
+ updated, _ := m.Update(tea.KeyMsg{Type: tea.KeyEnter})
+ m = updated.(appModel)
+ for _, r := range []rune("deploy-skill") {
+ 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.confirming || !strings.Contains(m.confirmError, "Type yes") {
+ t.Fatalf("expected skill name not to confirm deletion, confirming=%v err=%q cmd=%v", m.confirming, m.confirmError, cmd)
+ }
+}
+
func TestSingleRemoveAcceptsYesConfirmation(t *testing.T) {
old := runExec
runExec = func(spec runner.ExecSpec) runner.Result {
@@ -1373,7 +1390,13 @@ func TestSingleRemoveAcceptsYesConfirmation(t *testing.T) {
}
}
-func TestBulkRemoveRequiresExactPhrase(t *testing.T) {
+func TestBulkRemoveAcceptsYesConfirmation(t *testing.T) {
+ old := runExec
+ runExec = func(spec runner.ExecSpec) runner.Result {
+ return runner.Result{Program: spec.Program, Args: spec.Args, Cwd: spec.Cwd, ExitCode: 0}
+ }
+ t.Cleanup(func() { runExec = old })
+
m := bulkActionTestModel(t.TempDir())
m.selectedKeys = map[string]bool{skillKey(m.result.Skills[0]): true, skillKey(m.result.Skills[1]): true}
m.commands = true
@@ -1386,8 +1409,8 @@ func TestBulkRemoveRequiresExactPhrase(t *testing.T) {
}
updated, cmd := m.Update(tea.KeyMsg{Type: tea.KeyEnter})
m = updated.(appModel)
- if cmd != nil || !m.confirming || !strings.Contains(m.confirmError, `Type "remove 2 skills" exactly`) {
- t.Fatalf("expected bulk remove to require exact phrase, confirming=%v err=%q cmd=%v", m.confirming, m.confirmError, cmd)
+ if cmd == nil || !m.running || m.commands {
+ t.Fatalf("expected bulk remove to accept yes and close actions, running=%v commands=%v cmd=%v", m.running, m.commands, cmd)
}
}
@@ -1437,8 +1460,8 @@ func TestConfirmationOverlayCopyMatchesRisk(t *testing.T) {
m.action = actionIndex(t, m, "Remove selected skill")
dangerOut := m.confirmationOverlay(appLayout{Width: 120, Height: 32})
- if !strings.Contains(dangerOut, "Type y or yes to confirm") || strings.Contains(dangerOut, `Type "deploy-skill"`) {
- t.Fatalf("expected single-remove y/yes copy, got %q", dangerOut)
+ if !strings.Contains(dangerOut, "Type yes to confirm") || strings.Contains(dangerOut, `Type "deploy-skill"`) || strings.Contains(dangerOut, "y / yes") {
+ t.Fatalf("expected single-remove yes-only copy, got %q", dangerOut)
}
m = bulkActionTestModel(t.TempDir())
@@ -1447,8 +1470,8 @@ func TestConfirmationOverlayCopyMatchesRisk(t *testing.T) {
m.action = actionIndex(t, m, "Remove 2 selected skills")
m.confirming = true
bulkOut := m.confirmationOverlay(appLayout{Width: 120, Height: 32})
- if !strings.Contains(bulkOut, `remove 2 skills`) || !strings.Contains(bulkOut, `to confirm`) || strings.Contains(bulkOut, "y / yes") {
- t.Fatalf("expected bulk-remove exact-phrase copy, got %q", bulkOut)
+ if !strings.Contains(bulkOut, `Remove 2 selected skills`) || !strings.Contains(bulkOut, `Type yes to confirm`) || strings.Contains(bulkOut, "y / yes") {
+ t.Fatalf("expected bulk-remove yes-only copy, got %q", bulkOut)
}
}
diff --git a/internal/tui/update.go b/internal/tui/update.go
index 8d3a136..074070e 100644
--- a/internal/tui/update.go
+++ b/internal/tui/update.go
@@ -984,38 +984,30 @@ func (m appModel) confirmAction() (tea.Model, tea.Cmd) {
}
func confirmationAccepted(input string, action actions.CommandPreview) bool {
- if requiresExactConfirmation(action) {
- return input == action.ConfirmValue && action.ConfirmValue != ""
- }
value := strings.TrimSpace(strings.ToLower(input))
+ if action.Dangerous {
+ return value == "yes"
+ }
if value == "" {
- return !action.Dangerous
+ return true
}
return value == "y" || value == "yes" || input == action.ConfirmValue
}
func confirmationError(action actions.CommandPreview) string {
- if requiresExactConfirmation(action) {
- return fmt.Sprintf("Type %q exactly, or press Esc to cancel.", action.ConfirmValue)
- }
if action.Dangerous {
- return "Type y or yes to confirm, or press Esc to cancel."
+ return "Type yes to confirm, or press Esc to cancel."
}
return "Press Enter to continue, or Esc to cancel."
}
-func requiresExactConfirmation(action actions.CommandPreview) bool {
- return action.Dangerous && action.ID == "bulk_remove"
-}
-
func (m appModel) executeAction(action actions.CommandPreview) (tea.Model, tea.Cmd) {
+ m.commands = false
if action.ID == "source_discover" {
- m.commands = false
m.actionResult = nil
return m.startDiscovery(action.ConfirmValue, true)
}
if action.Exec.Internal == "enable_skill" || action.Exec.Internal == "disable_skill" {
- m.commands = false
m.confirming = false
m.confirmInput = ""
m.confirmError = ""
diff --git a/internal/tui/view.go b/internal/tui/view.go
index ab3dcae..da33544 100644
--- a/internal/tui/view.go
+++ b/internal/tui/view.go
@@ -1306,7 +1306,7 @@ func (m appModel) footerText(width int, rows []skillsRow, actions []actions.Comm
if m.running {
text = "Working…"
} else if m.confirming {
- text = "type y/yes/phrase · enter confirm · esc cancel"
+ text = "type yes · enter confirm · esc cancel"
} else if m.searching {
text = "type search · enter apply · esc cancel · backspace edit"
} else if m.detailModal {
@@ -1563,23 +1563,17 @@ func (m *appModel) ensureSourceModalSelectionVisible() {
func (m appModel) confirmationOverlay(layout appLayout) string {
title := "Confirm action"
- phrase := ""
command := ""
dangerous := false
- exact := false
if m.pendingAction != nil {
title = compat.SanitizeMetadata(m.pendingAction.Title)
- phrase = compat.SanitizeMetadata(m.pendingAction.ConfirmValue)
command = compat.SanitizeMetadata(m.pendingAction.Command)
dangerous = m.pendingAction.Dangerous
- exact = requiresExactConfirmation(*m.pendingAction)
} else if acts := m.currentActions(); len(acts) > 0 && m.action < len(acts) {
action := acts[m.action]
title = compat.SanitizeMetadata(action.Title)
- phrase = compat.SanitizeMetadata(action.ConfirmValue)
command = compat.SanitizeMetadata(action.Command)
dangerous = action.Dangerous
- exact = requiresExactConfirmation(action)
}
headerStyle := sectionHeaderStyle
borderColor := actionBorderColor
@@ -1588,12 +1582,8 @@ func (m appModel) confirmationOverlay(layout appLayout) string {
if dangerous {
headerStyle = errorStyle.Bold(true)
borderColor = lipgloss.Color("203")
- placeholder = "y / yes"
- instruction = "Type y or yes to confirm, or Esc to cancel."
- if exact {
- placeholder = phrase
- instruction = fmt.Sprintf("Type %q to confirm, or Esc to cancel.", phrase)
- }
+ placeholder = "yes"
+ instruction = "Type yes to confirm, or Esc to cancel."
}
lines := []string{
headerStyle.Render(title),