Skip to content

mission control for agent skills

fix(tui): require scoped symlink cleanup identity

Alvin Unreal24bb1f711a1c
diff --git a/internal/tui/tui_test.go b/internal/tui/tui_test.go
index 519db73..60657d9 100644
--- a/internal/tui/tui_test.go
+++ b/internal/tui/tui_test.go
@@ -679,6 +679,38 @@ func TestDeleteBrokenSymlinkFailureRescans(t *testing.T) {
}
}
+func TestDeleteBrokenSymlinkRequiresScopedIdentity(t *testing.T) {
+ cwd := t.TempDir()
+ projectLink := filepath.Join(cwd, "project-broken")
+ globalLink := filepath.Join(cwd, "global-broken")
+ if err := os.Symlink(filepath.Join(cwd, "missing-project"), projectLink); err != nil {
+ t.Fatal(err)
+ }
+ if err := os.Symlink(filepath.Join(cwd, "missing-global"), globalLink); err != nil {
+ t.Fatal(err)
+ }
+ m := appModel{cwd: cwd, width: 120, height: 32, selected: 1, result: model.ScanResult{Skills: []*model.Skill{
+ {Name: "Duplicate", Scope: model.ScopeGlobal, ObservedPaths: []model.ObservedPath{{Path: globalLink, Status: model.StatusBrokenSymlink}}},
+ {Name: "Duplicate", Scope: model.ScopeProject, ObservedPaths: []model.ObservedPath{{Path: projectLink, Status: model.StatusBrokenSymlink}}},
+ }}}
+ action := actions.CommandPreview{ID: "delete_broken_symlink", ConfirmValue: "Duplicate", Exec: actions.ExecSpec{Internal: "delete_broken_symlink"}}
+
+ updated, cmd := m.executeAction(action)
+ next := updated.(appModel)
+ if cmd != nil {
+ t.Fatalf("expected malformed delete action not to run, got cmd=%v", cmd)
+ }
+ if next.actionResult == nil || next.actionResult.ExitCode != -1 || !strings.Contains(next.actionResult.Err, "missing scoped skill identity") {
+ t.Fatalf("expected missing scoped identity error, got %#v", next.actionResult)
+ }
+ if _, err := os.Lstat(projectLink); err != nil {
+ t.Fatalf("expected project link to remain, err=%v", err)
+ }
+ if _, err := os.Lstat(globalLink); err != nil {
+ t.Fatalf("expected global link to remain, err=%v", err)
+ }
+}
+
func TestDeleteBrokenSymlinkTargetsMatchingScope(t *testing.T) {
cwd := t.TempDir()
projectLink := filepath.Join(cwd, "project-broken")
@@ -701,6 +733,11 @@ func TestDeleteBrokenSymlinkTargetsMatchingScope(t *testing.T) {
if cmd == nil || next.actionResult != nil {
t.Fatalf("expected scoped delete success with rescan, result=%#v cmd=%v", next.actionResult, cmd)
}
+ updated, _ = next.Update(cmd())
+ next = updated.(appModel)
+ if next.actionResult != nil {
+ t.Fatalf("expected scoped delete result to stay clear after rescan, got %#v", next.actionResult)
+ }
if _, err := os.Lstat(projectLink); !os.IsNotExist(err) {
t.Fatalf("expected project broken symlink to be deleted, lstat err=%v", err)
}
diff --git a/internal/tui/update.go b/internal/tui/update.go
index 64e7917..3b59af5 100644
--- a/internal/tui/update.go
+++ b/internal/tui/update.go
@@ -1140,12 +1140,13 @@ func (m appModel) executeAction(action actions.CommandPreview) (tea.Model, tea.C
m.confirming = false
m.confirmInput = ""
m.confirmError = ""
- targetScope := ""
- targetName := action.ConfirmValue
- if len(action.Exec.Args) >= 2 {
- targetScope = action.Exec.Args[0]
- targetName = action.Exec.Args[1]
+ if len(action.Exec.Args) < 2 {
+ m.actionResult = &runner.Result{Program: "delete-broken-symlink", Args: []string{action.ConfirmValue}, ExitCode: -1, Err: "delete action is missing scoped skill identity"}
+ m.syncViewport()
+ return m, nil
}
+ targetScope := action.Exec.Args[0]
+ targetName := action.Exec.Args[1]
removed, failed := 0, 0
firstErr := ""
for _, sk := range m.result.Skills {