Skip to content

mission control for agent skills

Polish v1 actions UX

Alvin Unrealfce32dc7d501
diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml
new file mode 100644
index 0000000..336d9da
--- /dev/null
+++ b/.github/workflows/ci.yml
@@ -0,0 +1,17 @@
+name: CI
+
+on:
+ push:
+ branches: [main]
+ pull_request:
+
+jobs:
+ test:
+ runs-on: ubuntu-latest
+ steps:
+ - uses: actions/checkout@v4
+ - uses: actions/setup-go@v5
+ with:
+ go-version-file: go.mod
+ - run: go test ./...
+ - run: go build ./cmd/lazyskills
diff --git a/LICENSE b/LICENSE
new file mode 100644
index 0000000..7e6dfc1
--- /dev/null
+++ b/LICENSE
@@ -0,0 +1,21 @@
+MIT License
+
+Copyright (c) 2026 LazySkills contributors
+
+Permission is hereby granted, free of charge, to any person obtaining a copy
+of this software and associated documentation files (the "Software"), to deal
+in the Software without restriction, including without limitation the rights
+to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+copies of the Software, and to permit persons to whom the Software is
+furnished to do so, subject to the following conditions:
+
+The above copyright notice and this permission notice shall be included in all
+copies or substantial portions of the Software.
+
+THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
+SOFTWARE.
diff --git a/README.md b/README.md
new file mode 100644
index 0000000..2b041d7
--- /dev/null
+++ b/README.md
@@ -0,0 +1,92 @@
+# LazySkills
+
+LazySkills is a terminal control room for agent skills. It shows what skills are installed, which agents can see them, why visibility may be broken, and provides guarded actions for common skill operations.
+
+It is designed to complement the official `skills` CLI, not replace it.
+
+## Features
+
+- LazyGit-style Bubble Tea TUI
+- Project and global skill inventory
+- Agent compatibility diagnostics based on the upstream `skills` registry
+- 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
+- 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
+- Structured command execution with confirmation, captured output, and rescan after successful mutations
+
+## Install / build
+
+```bash
+go build ./cmd/lazyskills
+```
+
+Then run:
+
+```bash
+./lazyskills
+```
+
+Or scan as JSON:
+
+```bash
+./lazyskills scan --json
+./lazyskills scan --json --cwd /path/to/project
+```
+
+## Usage
+
+```bash
+lazyskills [--cwd <path>]
+lazyskills scan --json [--cwd <path>]
+```
+
+Common TUI keys:
+
+| Key | Action |
+| --- | --- |
+| `↑/↓`, `j/k` | Move selection |
+| `tab`, `shift+tab`, `←/→` | Change project/global scope filter |
+| `a` | Cycle agent filter |
+| `/` | Search skills |
+| `c` | Show guarded actions |
+| `enter` | Run selected action when actions are visible |
+| `r` | Refresh scan |
+| `?` | Toggle help |
+| `q` | Quit |
+
+Mutating actions require confirmation. Remove requires typing the exact installed directory identity.
+
+## How actions work
+
+LazySkills delegates install/update/remove behavior to the official `skills` CLI. It resolves commands as:
+
+1. `skills` if available on `PATH`
+2. `npx --yes skills` as fallback
+
+Commands are executed as structured argv, not shell strings. Output is captured, sanitized, capped, and displayed in the TUI. Successful mutations trigger a rescan.
+
+## Supported agents
+
+LazySkills mirrors the upstream `vercel-labs/skills` agent registry, including universal `.agents/skills` agents, agent-specific skill directories, global support, and installed-agent detection heuristics.
+
+The registry is manually ported for now. A generated parity check is a planned follow-up.
+
+## 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.
+
+## Development
+
+```bash
+go test ./...
+go build ./cmd/lazyskills
+```
diff --git a/internal/actions/actions.go b/internal/actions/actions.go
index cb0a8de..0428ed9 100644
--- a/internal/actions/actions.go
+++ b/internal/actions/actions.go
@@ -1,6 +1,7 @@
package actions
import (
+ "os"
"os/exec"
"path/filepath"
"strings"
@@ -46,8 +47,11 @@ func ForSkillWithResolver(sk *model.Skill, resolve SkillsResolver) []CommandPrev
if resolve == nil {
resolve = ResolveSkillsCommand
}
- previews := []CommandPreview{
- newInternalPreview("refresh", "Refresh LazySkills", "refresh", "Rescan skills without leaving LazySkills.", false),
+ previews := []CommandPreview{}
+ if open, ok, reason := openEditorAction(sk); ok {
+ previews = append(previews, open)
+ } else {
+ previews = append(previews, unavailablePreview("Open selected skill", reason))
}
if addSource, skillFilter, ok, reason := addIdentity(sk); ok {
@@ -77,6 +81,37 @@ func ForSkillWithResolver(sk *model.Skill, resolve SkillsResolver) []CommandPrev
return previews
}
+func openEditorAction(sk *model.Skill) (CommandPreview, bool, string) {
+ editor := os.Getenv("EDITOR")
+ if editor == "" {
+ return CommandPreview{}, false, "$EDITOR is not set"
+ }
+ parts := strings.Fields(editor)
+ if len(parts) == 0 || !safeEditorToken(parts[0]) {
+ return CommandPreview{}, false, "$EDITOR is empty or unsafe"
+ }
+ for _, arg := range parts[1:] {
+ if !safeEditorArg(arg) {
+ return CommandPreview{}, false, "$EDITOR arguments are unsafe"
+ }
+ }
+ target := firstRawNonEmpty(sk.SkillPath, sk.CanonicalPath)
+ if target == "" {
+ return CommandPreview{}, false, "skill path is unavailable"
+ }
+ if !safeExecValue(target) {
+ return CommandPreview{}, false, "skill path contains unsafe characters"
+ }
+ args := append([]string{}, parts[1:]...)
+ args = append(args, target)
+ preview := newPreview("open_skill", "Open selected skill", parts[0], args, "Open this skill in $EDITOR. LazySkills releases the terminal while the editor runs.", false, false, false, "")
+ if !preview.Available {
+ return CommandPreview{}, false, preview.Reason
+ }
+ preview.Exec.Interactive = true
+ return preview, true, ""
+}
+
func ResolveSkillsCommand() (string, []string) {
if _, err := exec.LookPath("skills"); err == nil {
return "skills", nil
@@ -84,12 +119,6 @@ func ResolveSkillsCommand() (string, []string) {
return "npx", []string{"--yes", "skills"}
}
-func newInternalPreview(id, title, internal, description string, mutates bool) CommandPreview {
- preview := CommandPreview{ID: id, Title: title, Description: description, Mutates: mutates, Available: true, Exec: ExecSpec{Internal: internal}}
- preview.Command = title
- return preview
-}
-
func newPreview(id, title, program string, args []string, description string, mutates, confirm, dangerous bool, confirmValue string) CommandPreview {
if !safeExecValue(program) {
return unavailablePreview(title, "program is empty or unsafe")
@@ -226,6 +255,14 @@ func safeExecValue(value string) bool {
return compat.SanitizeMetadata(value) == value && !strings.ContainsAny(value, "\x00\x1b\r\n")
}
+func safeEditorToken(value string) bool {
+ return safeExecValue(value) && !strings.HasPrefix(value, "-") && !strings.ContainsAny(value, "'\"$`\\!*?[]{}()&;<>|")
+}
+
+func safeEditorArg(value string) bool {
+ return safeExecValue(value) && !strings.ContainsAny(value, "'\"$`\\!*?[]{}()&;<>|")
+}
+
func safeToken(value string) string {
value = compat.SanitizeMetadata(value)
if value == "" || strings.HasPrefix(value, "-") || strings.ContainsAny(value, " \t\n'\"$`\\!*?[]{}()&;<>|") {
diff --git a/internal/actions/actions_test.go b/internal/actions/actions_test.go
index f2ec343..cbd63dd 100644
--- a/internal/actions/actions_test.go
+++ b/internal/actions/actions_test.go
@@ -8,6 +8,7 @@ import (
)
func TestForSkillBuildsStructuredSanitizedCommandPreviews(t *testing.T) {
+ t.Setenv("EDITOR", "")
sk := &model.Skill{
Name: "Deploy Skill",
Scope: model.ScopeGlobal,
@@ -38,6 +39,26 @@ func TestForSkillBuildsStructuredSanitizedCommandPreviews(t *testing.T) {
}
}
+func TestOpenEditorActionUsesSafeEditorAndSkillPath(t *testing.T) {
+ t.Setenv("EDITOR", "vim -n")
+ previews := ForSkill(&model.Skill{Name: "Deploy", Scope: model.ScopeProject, SkillPath: "/tmp/deploy/SKILL.md"})
+ open := previewByTitle(t, previews, "Open selected skill")
+ if !open.Available || !open.Exec.Interactive || open.Exec.Program != "vim" {
+ t.Fatalf("expected interactive editor action, got %#v", open)
+ }
+ if len(open.Exec.Args) != 2 || open.Exec.Args[0] != "-n" || open.Exec.Args[1] != "/tmp/deploy/SKILL.md" {
+ t.Fatalf("unexpected editor args: %#v", open.Exec.Args)
+ }
+}
+
+func TestOpenEditorRejectsUnsafeEditor(t *testing.T) {
+ t.Setenv("EDITOR", "vim;rm")
+ open := previewByTitle(t, ForSkill(&model.Skill{Name: "Deploy", Scope: model.ScopeProject, SkillPath: "/tmp/deploy/SKILL.md"}), "Open selected skill")
+ if open.Available {
+ t.Fatalf("expected unsafe editor unavailable: %#v", open)
+ }
+}
+
func TestUnsafeRawValuesSuppressExecActions(t *testing.T) {
previews := ForSkill(&model.Skill{Name: "Deploy\x1b[31m", Scope: model.ScopeProject, CanonicalPath: "/tmp/deploy", LocalLock: &model.LocalLockEntry{Source: "owner/repo"}})
add := previewByTitle(t, previews, "Reinstall/update selected skill")
diff --git a/internal/tui/tui.go b/internal/tui/tui.go
index e626a3a..fbc8f77 100644
--- a/internal/tui/tui.go
+++ b/internal/tui/tui.go
@@ -2,6 +2,7 @@ package tui
import (
"fmt"
+ "os/exec"
"sort"
"strings"
@@ -41,6 +42,7 @@ type appModel struct {
action int
confirming bool
confirmInput string
+ confirmError string
running bool
actionResult *runner.Result
width int
@@ -69,6 +71,7 @@ type appLayout struct {
const (
minLayoutWidth = 40
minLayoutHeight = 7
+ appVersion = "v1"
)
var (
@@ -78,6 +81,14 @@ var (
dimStyle = lipgloss.NewStyle().Foreground(lipgloss.Color("241"))
errorStyle = lipgloss.NewStyle().Foreground(lipgloss.Color("203"))
runExec = runner.OSRunner{}.Run
+
+ // Action Mode UI Polish Styles
+ actionTitleStyle = lipgloss.NewStyle().Bold(true).Foreground(lipgloss.Color("230")).Background(lipgloss.Color("62")).Padding(0, 1)
+ activeActionStyle = lipgloss.NewStyle().Foreground(lipgloss.Color("230")).Background(lipgloss.Color("62"))
+ actionNormalStyle = lipgloss.NewStyle().Foreground(lipgloss.Color("255"))
+ actionBorderColor = lipgloss.Color("62")
+ runningStyle = lipgloss.NewStyle().Foreground(lipgloss.Color("208")).Bold(true)
+ successStyle = lipgloss.NewStyle().Foreground(lipgloss.Color("114")).Bold(true)
)
type snapshotMsg struct {
@@ -121,6 +132,7 @@ func (m appModel) Update(msg tea.Msg) (tea.Model, tea.Cmd) {
m.result = msg.result
m.err = msg.err
m.clampSelection()
+ m.actionResult = nil
m.syncViewport()
case actionResultMsg:
m.running = false
@@ -144,15 +156,22 @@ func (m appModel) Update(msg tea.Msg) (tea.Model, tea.Cmd) {
case "esc":
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)
+ return m, cmd
case "enter":
return m.confirmAction()
case "backspace", "ctrl+h":
if len(m.confirmInput) > 0 {
m.confirmInput = m.confirmInput[:len(m.confirmInput)-1]
+ m.confirmError = ""
}
default:
if len(key) == 1 {
m.confirmInput += key
+ m.confirmError = ""
}
}
m.syncViewport()
@@ -160,7 +179,11 @@ func (m appModel) Update(msg tea.Msg) (tea.Model, tea.Cmd) {
}
if m.searching {
switch key {
- case "esc", "enter":
+ case "esc":
+ m.search = ""
+ m.selected = 0
+ m.searching = false
+ case "enter":
m.searching = false
case "backspace", "ctrl+h":
if len(m.search) > 0 {
@@ -177,8 +200,26 @@ func (m appModel) Update(msg tea.Msg) (tea.Model, tea.Cmd) {
m.syncViewport()
return m, nil
}
+ if !m.searching && (key == "backspace" || key == "ctrl+h") && len(m.search) > 0 {
+ m.search = m.search[:len(m.search)-1]
+ m.selected = 0
+ m.clampSelection()
+ m.actionResult = nil
+ m.syncViewport()
+ return m, nil
+ }
switch key {
+ case "esc":
+ if m.commands {
+ m.commands = false
+ } else if m.agent != "" {
+ m.agent = ""
+ m.selected = 0
+ m.action = 0
+ m.actionResult = nil
+ m.viewport.GotoTop()
+ }
case "q", "ctrl+c":
return m, tea.Quit
case "?":
@@ -198,29 +239,41 @@ func (m appModel) Update(msg tea.Msg) (tea.Model, tea.Cmd) {
case "a":
m.agent = m.nextAgentFilter()
m.selected = 0
+ m.action = 0
+ m.actionResult = nil
+ m.viewport.GotoTop()
+ case "A":
+ m.agent = ""
+ m.selected = 0
+ m.action = 0
+ m.actionResult = nil
m.viewport.GotoTop()
case "tab", "right", "l":
m.filter = (m.filter + 1) % 3
m.selected = 0
+ m.actionResult = nil
m.viewport.GotoTop()
case "shift+tab", "left", "h":
m.filter = (m.filter + 2) % 3
m.selected = 0
+ m.actionResult = nil
m.viewport.GotoTop()
case "down", "j":
if m.commands {
m.action++
} else {
m.selected++
+ m.actionResult = nil
+ m.viewport.GotoTop()
}
- m.viewport.GotoTop()
case "up", "k":
if m.commands {
m.action--
} else {
m.selected--
+ m.actionResult = nil
+ m.viewport.GotoTop()
}
- m.viewport.GotoTop()
case "pgdown", "ctrl+d":
var cmd tea.Cmd
m.viewport, cmd = m.viewport.Update(msg)
@@ -273,6 +326,7 @@ func (m appModel) startAction() (tea.Model, tea.Cmd) {
if action.RequiresConfirm {
m.confirming = true
m.confirmInput = ""
+ m.confirmError = ""
m.actionResult = nil
m.syncViewport()
return m, nil
@@ -287,8 +341,7 @@ func (m appModel) confirmAction() (tea.Model, tea.Cmd) {
}
action := actions[m.action]
if m.confirmInput != action.ConfirmValue {
- m.actionResult = &runner.Result{Err: "confirmation did not match", ExitCode: -1}
- m.confirming = false
+ m.confirmError = "Confirmation did not match. Try again or press Esc to cancel."
m.confirmInput = ""
m.syncViewport()
return m, nil
@@ -301,11 +354,30 @@ func (m appModel) executeAction(action actions.CommandPreview) (tea.Model, tea.C
m.actionResult = nil
return m, loadSnapshot(m.cwd)
}
+ if action.Exec.Interactive {
+ cmd := exec.Command(action.Exec.Program, action.Exec.Args...)
+ cmd.Dir = m.cwd
+ m.running = true
+ m.actionResult = nil
+ m.confirming = false
+ m.confirmInput = ""
+ m.confirmError = ""
+ m.syncViewport()
+ return m, tea.ExecProcess(cmd, func(err error) tea.Msg {
+ result := runner.Result{Program: action.Exec.Program, Args: action.Exec.Args, Cwd: m.cwd, ExitCode: 0}
+ if err != nil {
+ result.ExitCode = -1
+ result.Err = err.Error()
+ }
+ return actionResultMsg{result: result, mutates: action.Mutates}
+ })
+ }
spec := runner.ExecSpec{Program: action.Exec.Program, Args: action.Exec.Args, Cwd: m.cwd}
m.running = true
m.actionResult = nil
m.confirming = false
m.confirmInput = ""
+ m.confirmError = ""
m.syncViewport()
return m, func() tea.Msg {
result := runExec(spec)
@@ -361,6 +433,9 @@ func (m appModel) View() string {
leftStyle := paneStyle(layout.Left)
listStyle := paneStyle(layout.List)
detailStyle := paneStyle(layout.Detail)
+ if viewModel.commands {
+ detailStyle = detailStyle.BorderForeground(actionBorderColor)
+ }
left := leftStyle.Render(fitLines(viewModel.filterPane(layout.Left.ContentWidth), layout.Left.ContentHeight))
list := listStyle.Render(fitLines(viewModel.listPane(layout.List.ContentHeight, layout.List.ContentWidth), layout.List.ContentHeight))
detail := detailStyle.Render(viewModel.detailPane())
@@ -402,7 +477,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", "c commands", "/ search", "r refresh", "? help", "q quit")
+ 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")
}
return strings.Join(lines, "\n")
}
@@ -440,10 +515,12 @@ func (m appModel) listPane(height, width int) string {
label += " " + agentVisibilityBadge(items[i], m.agent)
}
if len(view.HealthIssues) > 0 {
- label += fmt.Sprintf(" !%d", len(view.HealthIssues))
+ label += fmt.Sprintf(" ⚠ %d", len(view.HealthIssues))
}
if i == m.selected {
lines = append(lines, selectedStyle.Render(truncate(label, width)))
+ } else if len(view.HealthIssues) > 0 {
+ lines = append(lines, errorStyle.Render(truncate(label, width)))
} else {
lines = append(lines, truncate(label, width))
}
@@ -501,6 +578,8 @@ func (m appModel) detailLines(width int) []string {
}
if m.commands {
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(items[m.selected], max(1, width-4))...)
return lines
}
@@ -545,10 +624,10 @@ func (m appModel) visibilitySummary(view display.SkillView) []string {
}
func (m appModel) commandPreview(sk *model.Skill, width int) []string {
- lines := []string{titleStyle.Render("Actions")}
- lines = append(lines, dimStyle.Render("j/k choose, enter run, esc cancel confirmation"))
+ lines := []string{actionTitleStyle.Render(" Actions ")}
+ lines = append(lines, dimStyle.Render(" j/k choose, enter run, c hide"))
if m.running {
- lines = append(lines, "", "Running action...")
+ lines = append(lines, "", " "+runningStyle.Render("Running action..."))
}
if m.confirming {
current := m.currentActions()
@@ -556,20 +635,31 @@ func (m appModel) commandPreview(sk *model.Skill, width int) []string {
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, "> "+compat.SanitizeMetadata(m.confirmInput))
+ 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)+"_")
}
if m.actionResult != nil {
lines = append(lines, "")
lines = append(lines, m.renderActionResult(width)...)
}
- for i, preview := range actions.ForSkill(sk) {
+ for i, preview := range m.currentActions() {
selector := " "
if i == m.action {
selector = "› "
}
if !preview.Available {
- lines = append(lines, "", selector+fmt.Sprintf("%s (unavailable)", compat.SanitizeMetadata(preview.Title)))
- lines = append(lines, wrap(compat.SanitizeMetadata(preview.Reason), width))
+ titleText := fmt.Sprintf("%s (unavailable)", compat.SanitizeMetadata(preview.Title))
+ if i == m.action {
+ lines = append(lines, "", activeActionStyle.Render(selector+titleText))
+ } else {
+ lines = append(lines, "", dimStyle.Render(selector+titleText))
+ }
+ if preview.Reason != "" {
+ lines = append(lines, indent(wrap(compat.SanitizeMetadata(preview.Reason), width-2), " "))
+ }
continue
}
marker := "read-only"
@@ -579,10 +669,20 @@ func (m appModel) commandPreview(sk *model.Skill, width int) []string {
if preview.Dangerous {
marker += ", dangerous"
}
- lines = append(lines, "", selector+fmt.Sprintf("%s (%s)", compat.SanitizeMetadata(preview.Title), marker))
- lines = append(lines, truncate(compat.SanitizeMetadata(preview.Command), width))
- if preview.Description != "" {
- lines = append(lines, wrap(compat.SanitizeMetadata(preview.Description), width))
+
+ titleText := fmt.Sprintf("%s (%s)", compat.SanitizeMetadata(preview.Title), marker)
+ if i == m.action {
+ lines = append(lines, "", activeActionStyle.Render(selector+titleText))
+ lines = append(lines, " "+actionNormalStyle.Render(truncate(compat.SanitizeMetadata(preview.Command), width-2)))
+ if preview.Description != "" {
+ lines = append(lines, indent(wrap(compat.SanitizeMetadata(preview.Description), width-2), " "))
+ }
+ } else {
+ lines = append(lines, "", selector+titleText)
+ lines = append(lines, dimStyle.Render(" "+truncate(compat.SanitizeMetadata(preview.Command), width-2)))
+ if preview.Description != "" {
+ lines = append(lines, indent(dimStyle.Render(wrap(compat.SanitizeMetadata(preview.Description), width-2)), " "))
+ }
}
}
return lines
@@ -593,22 +693,22 @@ func (m appModel) renderActionResult(width int) []string {
return nil
}
result := m.actionResult
- status := "success"
+ status := successStyle.Render("success")
if result.ExitCode != 0 || result.Err != "" {
- status = "failed"
+ status = errorStyle.Render("failed")
}
- lines := []string{fmt.Sprintf("Result: %s (exit %d)", status, result.ExitCode)}
+ lines := []string{fmt.Sprintf(" Result: %s (exit %d)", status, result.ExitCode)}
if result.Err != "" {
- lines = append(lines, wrap(compat.SanitizeMetadata(result.Err), width))
+ lines = append(lines, indent(wrap(compat.SanitizeMetadata(result.Err), width-2), " "))
}
if result.Stdout != "" {
- lines = append(lines, "stdout:", fitLines(wrapText(result.Stdout, width), 8))
+ lines = append(lines, " stdout:", fitLines(indent(wrapText(result.Stdout, width-4), " "), 8))
}
if result.Stderr != "" {
- lines = append(lines, "stderr:", fitLines(wrapText(result.Stderr, width), 8))
+ lines = append(lines, " stderr:", fitLines(indent(wrapText(result.Stderr, width-4), " "), 8))
}
if result.Truncated {
- lines = append(lines, dimStyle.Render("output truncated"))
+ lines = append(lines, dimStyle.Render(" output truncated"))
}
return lines
}
@@ -616,11 +716,11 @@ func (m appModel) renderActionResult(width int) []string {
func (m appModel) footer() string {
mode := ""
if m.searching {
- mode = " search mode: type to filter, esc/enter to leave"
+ mode = " " + lipgloss.NewStyle().Foreground(lipgloss.Color("212")).Bold(true).Render("SEARCH MODE") + " : type to filter, esc/enter to leave"
} else if m.commands {
- mode = " actions: enter run, c hide"
+ mode = " " + lipgloss.NewStyle().Foreground(lipgloss.Color("117")).Bold(true).Render("ACTION MODE") + " : j/k choose, enter run, c hide"
}
- return dimStyle.Render("LazySkills actions are guarded." + mode)
+ return dimStyle.Render("LazySkills "+appVersion) + mode
}
func (m appModel) filteredSkills() []*model.Skill {
@@ -649,23 +749,25 @@ func (m appModel) filteredSkills() []*model.Skill {
}
func (m appModel) agentFilters() []string {
- if len(m.result.Agents) == 0 {
- ids := []string{}
- for _, agent := range agents.InitialAgents() {
- if agent.Name == "universal" {
- continue
- }
- ids = append(ids, agent.Name)
- }
- sort.Strings(ids)
- return ids
- }
observed := map[string]bool{}
for _, skill := range m.result.Skills {
for _, path := range skill.ObservedPaths {
observed[path.Agent] = true
}
}
+ if len(m.result.Agents) == 0 {
+ ids := make([]string, 0, len(observed))
+ for agent := range observed {
+ if agent != "" && agent != "universal" {
+ ids = append(ids, agent)
+ }
+ }
+ sort.Strings(ids)
+ if len(ids) > 0 {
+ return ids
+ }
+ return supportedAgentIDs()
+ }
detected, rest := []string{}, []string{}
for _, agent := range m.result.Agents {
if agent.Name == "universal" {
@@ -679,9 +781,24 @@ func (m appModel) agentFilters() []string {
}
sort.Strings(detected)
sort.Strings(rest)
+ if len(detected) > 0 {
+ return detected
+ }
return append(detected, rest...)
}
+func supportedAgentIDs() []string {
+ ids := []string{}
+ for _, agent := range agents.InitialAgents() {
+ if agent.Name == "universal" {
+ continue
+ }
+ ids = append(ids, agent.Name)
+ }
+ sort.Strings(ids)
+ return ids
+}
+
func (m appModel) nextAgentFilter() string {
agents := m.agentFilters()
if len(agents) == 0 {
@@ -781,6 +898,17 @@ func wrapText(s string, width int) string {
return wordwrap.String(s, width)
}
+func indent(s string, prefix string) string {
+ if s == "" {
+ return ""
+ }
+ lines := strings.Split(s, "\n")
+ for i, line := range lines {
+ lines[i] = prefix + line
+ }
+ return strings.Join(lines, "\n")
+}
+
func truncate(s string, width int) string {
runes := []rune(s)
if width <= 1 || len(runes) <= width {
diff --git a/internal/tui/tui_test.go b/internal/tui/tui_test.go
index c226d7c..d6c9240 100644
--- a/internal/tui/tui_test.go
+++ b/internal/tui/tui_test.go
@@ -39,10 +39,10 @@ func TestErrorViewIsSanitized(t *testing.T) {
}
}
-func TestViewRendersReadOnlyFooter(t *testing.T) {
+func TestViewRendersQuietVersionFooter(t *testing.T) {
m := appModel{width: 100, height: 30, result: model.ScanResult{Skills: []*model.Skill{{Name: "Build", Description: "Build desc", Scope: model.ScopeProject}}}}
out := m.View()
- if !strings.Contains(out, "LazySkills actions are guarded") || !strings.Contains(out, "Build") {
+ if !strings.Contains(out, "LazySkills v1") || strings.Contains(out, "actions are guarded") || !strings.Contains(out, "Build") {
t.Fatalf("unexpected view: %s", out)
}
}
@@ -63,20 +63,35 @@ func TestNextAgentFilterCyclesThroughObservedAgents(t *testing.T) {
{Name: "A", ObservedPaths: []model.ObservedPath{{Agent: "opencode"}, {Agent: "cursor"}}},
}}}
first := m.nextAgentFilter()
- if first != "adal" {
- t.Fatalf("expected first supported agent adal, got %q", first)
+ if first != "cursor" {
+ t.Fatalf("expected first observed agent cursor, got %q", first)
}
m.agent = first
second := m.nextAgentFilter()
- if second != "aider-desk" {
- t.Fatalf("expected second supported agent aider-desk, got %q", second)
+ if second != "opencode" {
+ t.Fatalf("expected second observed agent opencode, got %q", second)
}
- m.agent = "zenflow"
+ m.agent = second
if got := m.nextAgentFilter(); got != "" {
t.Fatalf("expected cycle back to all, got %q", got)
}
}
+func TestAgentFilterCyclesDetectedAgentsBeforeSupportedFallback(t *testing.T) {
+ m := appModel{result: model.ScanResult{Agents: []model.AgentState{
+ {Name: "opencode", Display: "OpenCode", Detected: true},
+ {Name: "cursor", Display: "Cursor"},
+ {Name: "claude-code", Display: "Claude Code", Detected: true},
+ }}}
+ if got := m.agentFilters(); strings.Join(got, ",") != "claude-code,opencode" {
+ t.Fatalf("expected only detected agents in rotation, got %#v", got)
+ }
+ m = appModel{result: model.ScanResult{Agents: []model.AgentState{{Name: "opencode", Display: "OpenCode"}}}}
+ if got := m.agentFilters(); len(got) != 1 || got[0] != "opencode" {
+ t.Fatalf("expected fallback to supported agents when none detected, got %#v", got)
+ }
+}
+
func TestAgentFilterCanSelectSupportedAgentWithNoSkills(t *testing.T) {
m := appModel{width: 100, height: 30, agent: "claude-code", result: model.ScanResult{Skills: []*model.Skill{
{Name: "OpenCode Skill", Description: "desc", Scope: model.ScopeProject, ObservedPaths: []model.ObservedPath{{Agent: "opencode"}}},
@@ -91,6 +106,22 @@ func TestAgentFilterCanSelectSupportedAgentWithNoSkills(t *testing.T) {
}
}
+func TestAgentFilterCanResetDirectlyToAll(t *testing.T) {
+ m := appModel{width: 100, height: 30, agent: "claude-code", result: model.ScanResult{Skills: []*model.Skill{
+ {Name: "OpenCode Skill", Description: "desc", Scope: model.ScopeProject, ObservedPaths: []model.ObservedPath{{Agent: "opencode"}}},
+ }}}
+ updated, _ := m.Update(tea.KeyMsg{Type: tea.KeyRunes, Runes: []rune{'A'}})
+ next := updated.(appModel)
+ if next.agent != "" {
+ t.Fatalf("expected A to reset agent filter, got %q", next.agent)
+ }
+ updated, _ = appModel{agent: "claude-code", result: m.result}.Update(tea.KeyMsg{Type: tea.KeyEsc})
+ next = updated.(appModel)
+ if next.agent != "" {
+ t.Fatalf("expected esc to reset agent filter when no mode is active, got %q", next.agent)
+ }
+}
+
func TestTopLevelScanHealthIsRenderedSanitized(t *testing.T) {
m := appModel{width: 100, height: 30, result: model.ScanResult{HealthIssues: []model.HealthIssue{{Type: "corrupt_lock", Message: "bad\x1b[31m lock"}}}}
out := m.View()
@@ -112,6 +143,9 @@ func TestCommandPreviewModeRendersWithoutExecuting(t *testing.T) {
if !strings.Contains(out, "Actions") || !strings.Contains(out, "Reinstall/update selected skill") || !strings.Contains(out, "skills add") || !strings.Contains(out, "--yes") {
t.Fatalf("expected actions in output: %q", out)
}
+ if strings.Contains(out, "Refresh LazySkills") {
+ t.Fatalf("refresh belongs on r key, not action list: %q", out)
+ }
}
func TestActiveAgentVisibilityReasonIsRendered(t *testing.T) {
@@ -146,6 +180,20 @@ func TestAgentFilterListMarksNonVisibleSkills(t *testing.T) {
}
}
+func TestListRendersIssueRowsInRedWithSubtleBadge(t *testing.T) {
+ m := appModel{width: 120, height: 32, selected: 1, result: model.ScanResult{Skills: []*model.Skill{
+ {Name: "Healthy", Scope: model.ScopeProject},
+ {Name: "Problem", Scope: model.ScopeProject, HealthIssues: []model.HealthIssue{{Type: "missing_file", Message: "missing SKILL.md"}}},
+ }}}
+ out := m.View()
+ if !strings.Contains(out, "Problem [project] ⚠ 1") {
+ t.Fatalf("expected subtle issue badge, got %q", out)
+ }
+ if strings.Contains(out, "BROKEN") {
+ t.Fatalf("issue badge should stay subtle, got %q", out)
+ }
+}
+
func TestCommandPreviewToggle(t *testing.T) {
m := appModel{}
updated, _ := m.Update(tea.KeyMsg{Type: tea.KeyRunes, Runes: []rune{'c'}})
@@ -163,7 +211,7 @@ func TestActionConfirmationCancelDoesNotExecute(t *testing.T) {
m := actionTestModel(t.TempDir())
m.commands = true
- m.action = 1
+ m.action = actionIndex(t, m, "Reinstall/update selected skill")
updated, cmd := m.Update(tea.KeyMsg{Type: tea.KeyEnter})
next := updated.(appModel)
if cmd != nil || !next.confirming {
@@ -189,7 +237,7 @@ func TestActionExecUsesProjectCwdAndPreventsDuplicateWhileRunning(t *testing.T)
m := actionTestModel(cwd)
m.commands = true
- m.action = 1
+ m.action = actionIndex(t, m, "Reinstall/update selected skill")
updated, _ := m.Update(tea.KeyMsg{Type: tea.KeyEnter})
m = updated.(appModel)
for _, r := range []rune("yes") {
@@ -223,7 +271,7 @@ func TestFailedMutationDoesNotTriggerRescan(t *testing.T) {
m := actionTestModel(cwd)
m.commands = true
- m.action = 1
+ m.action = actionIndex(t, m, "Reinstall/update selected skill")
updated, _ := m.Update(tea.KeyMsg{Type: tea.KeyEnter})
m = updated.(appModel)
for _, r := range []rune("yes") {
@@ -246,7 +294,7 @@ func TestRemoveRequiresExactTypedIdentity(t *testing.T) {
m := actionTestModel(t.TempDir())
m.result.Skills[0].CanonicalPath = "/tmp/deploy-skill"
m.commands = true
- m.action = 2
+ m.action = actionIndex(t, m, "Remove selected skill")
updated, _ := m.Update(tea.KeyMsg{Type: tea.KeyEnter})
m = updated.(appModel)
for _, r := range []rune("wrong") {
@@ -255,8 +303,8 @@ func TestRemoveRequiresExactTypedIdentity(t *testing.T) {
}
updated, cmd := m.Update(tea.KeyMsg{Type: tea.KeyEnter})
m = updated.(appModel)
- if cmd != nil || m.actionResult == nil || !strings.Contains(m.actionResult.Err, "confirmation") {
- t.Fatalf("expected failed confirmation without command, result=%#v cmd=%v", m.actionResult, cmd)
+ if cmd != nil || !m.confirming || !strings.Contains(m.confirmError, "Confirmation did not match") || 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)
}
}
@@ -270,6 +318,60 @@ func actionTestModel(cwd string) appModel {
}}}}
}
+func actionIndex(t *testing.T, m appModel, title string) int {
+ t.Helper()
+ for i, action := range m.currentActions() {
+ if action.Title == title {
+ return i
+ }
+ }
+ t.Fatalf("action %q not found in %#v", title, m.currentActions())
+ return 0
+}
+
+func TestActionSelectionDoesNotResetDetailScroll(t *testing.T) {
+ m := actionTestModel(t.TempDir())
+ for i := 0; i < 40; i++ {
+ m.result.Skills[0].HealthIssues = append(m.result.Skills[0].HealthIssues, model.HealthIssue{Type: "warning", Message: fmt.Sprintf("issue %d", i)})
+ }
+ m.height = 12
+ m.commands = true
+ m.syncViewport()
+ m.viewport.SetYOffset(5)
+ updated, _ := m.Update(tea.KeyMsg{Type: tea.KeyRunes, Runes: []rune{'j'}})
+ next := updated.(appModel)
+ if next.viewport.YOffset == 0 {
+ t.Fatalf("expected action selection not to reset detail scroll to top")
+ }
+}
+
+func TestActionResultClearsOnSkillSelectionChange(t *testing.T) {
+ m := appModel{width: 120, height: 32, actionResult: &runner.Result{ExitCode: 0}, result: model.ScanResult{Skills: []*model.Skill{
+ {Name: "One", Scope: model.ScopeProject},
+ {Name: "Two", Scope: model.ScopeProject},
+ }}}
+ updated, _ := m.Update(tea.KeyMsg{Type: tea.KeyRunes, Runes: []rune{'j'}})
+ next := updated.(appModel)
+ if next.actionResult != nil {
+ t.Fatalf("expected action result cleared on skill change")
+ }
+}
+
+func TestSearchEscapeClearsQueryAndBackspaceWorksOutsideSearch(t *testing.T) {
+ m := appModel{searching: true, search: "build", result: model.ScanResult{Skills: []*model.Skill{{Name: "Build", Scope: model.ScopeProject}}}}
+ updated, _ := m.Update(tea.KeyMsg{Type: tea.KeyEsc})
+ next := updated.(appModel)
+ if next.searching || next.search != "" {
+ t.Fatalf("expected esc to clear search, searching=%v search=%q", next.searching, next.search)
+ }
+ m = appModel{searching: false, search: "abc", result: model.ScanResult{Skills: []*model.Skill{{Name: "Build", Scope: model.ScopeProject}}}}
+ updated, _ = m.Update(tea.KeyMsg{Type: tea.KeyBackspace})
+ next = updated.(appModel)
+ if next.search != "ab" {
+ t.Fatalf("expected backspace outside search to trim query, got %q", next.search)
+ }
+}
+
func TestDetailPaneClipsLongPreview(t *testing.T) {
preview := strings.Repeat("line\n", 80)
m := appModel{width: 100, height: 20, result: model.ScanResult{Skills: []*model.Skill{{Name: "Long", Description: "desc", Scope: model.ScopeProject, Preview: preview}}}}