Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions cmd/skills.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ import (
tea "github.com/charmbracelet/bubbletea"
"github.com/spf13/cobra"

"github.com/render-oss/cli/pkg/command"
"github.com/render-oss/cli/pkg/tui"
"github.com/render-oss/cli/pkg/tui/views"
)
Expand All @@ -16,6 +17,10 @@ var skillsCmd = &cobra.Command{
Long: `Install and manage Render agent skills for AI coding tools such as Claude Code, Codex, OpenCode, and Cursor. Skills add deployment, debugging, and monitoring capabilities to your AI coding assistant.`,
RunE: func(cmd *cobra.Command, args []string) error {
ctx := cmd.Context()
// The command palette needs the TUI; otherwise list the subcommands.
if !command.IsInteractive(ctx) {
return cmd.Help()
}
stack := tui.GetStackFromContext(ctx)

commands := []views.PaletteCommand{
Expand Down
38 changes: 38 additions & 0 deletions cmd/skills_test.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
package cmd

import (
"fmt"
"testing"

"github.com/spf13/cobra"
"github.com/stretchr/testify/assert"
"github.com/stretchr/testify/require"
)

// Outside interactive mode, `render skills update` and bare `render skills`
// have no TUI stack to push onto. They used to panic; see
// https://github.com/render-oss/cli/issues/79.
func TestSkillsUpdate_NonInteractive(t *testing.T) {
for _, args := range [][]string{nil, {"-o", "text"}, {"-o", "json"}, {"--force", "--scope", "user", "-o", "text"}} {
t.Run(fmt.Sprint(args), func(t *testing.T) {
_, err := executeSkillsCommand(t, newSkillsUpdateCmd(), args...)

assert.EqualError(t, err, "`render skills update` can only be used in interactive mode")
})
}
}

func TestSkills_NonInteractivePrintsHelp(t *testing.T) {
for _, args := range [][]string{nil, {"-o", "text"}, {"-o", "json"}} {
t.Run(fmt.Sprint(args), func(t *testing.T) {
skills := &cobra.Command{Use: "skills", Short: skillsCmd.Short, RunE: skillsCmd.RunE}
skills.AddCommand(&cobra.Command{Use: "list", Short: "List installed Render skills", Run: func(*cobra.Command, []string) {}})

result, err := executeSkillsArgs(t, skills, args...)

require.NoError(t, err)
assert.Contains(t, result.Stdout, "render skills [subcommand]")
assert.Regexp(t, `list\s+List installed Render skills`, result.Stdout)
})
}
}
66 changes: 54 additions & 12 deletions cmd/skillslist.go
Original file line number Diff line number Diff line change
@@ -1,26 +1,42 @@
package cmd

import (
"fmt"

"github.com/spf13/cobra"

"github.com/render-oss/cli/pkg/command"
"github.com/render-oss/cli/pkg/skills"
"github.com/render-oss/cli/pkg/style"
"github.com/render-oss/cli/pkg/text"
"github.com/render-oss/cli/pkg/tui"
"github.com/render-oss/cli/pkg/tui/views"
)

var skillsListCmd = &cobra.Command{
Use: "list",
Short: "List installed Render skills and detected tools",
Long: `List installed Render skills and the AI tools they've been installed in. This reads from local state only, so the command doesn't require network access.
// newSkillsListCmd builds `render skills list`. loadState reads the local
// skills state, so tests can supply it without touching the home directory.
func newSkillsListCmd(loadState func() (*skills.LoadedState, error)) *cobra.Command {
cmd := &cobra.Command{
Use: "list",
Short: "List installed Render skills and detected tools",
Long: `List installed Render skills and the AI tools they've been installed in. This reads from local state only, so the command doesn't require network access.

Use --scope to filter by installation scope (user or project).`,
Example: ` # List all installed skills
Example: ` # List all installed skills
render skills list

# List project-scoped skills only
render skills list --scope project`,
SilenceUsage: true,
RunE: func(cmd *cobra.Command, args []string) error {
render skills list --scope project

# Output as JSON
render skills list -o json`,
SilenceUsage: true,
}

cmd.Flags().String("scope", "", "Filter skills by installation scope (user or project)")
setFlagPlaceholder(cmd.Flags(), "scope", "SCOPE")

cmd.RunE = func(cmd *cobra.Command, args []string) error {
scopeFilter, _ := cmd.Flags().GetString("scope")

var scope skills.Scope
Expand All @@ -32,6 +48,32 @@ Use --scope to filter by installation scope (user or project).`,
}
}

if nonInteractive, err := command.NonInteractive(cmd, func() (*skills.ListResult, error) {
loaded, err := loadState()
if err != nil {
return nil, err
}
// JSON and YAML carry the warnings in the output. Text prints them
// to stderr so they don't mix into the tables.
if format := command.GetFormatFromContext(cmd.Context()); format != nil && *format == command.TEXT {
warning := style.Status.Foreground(style.ColorWarning).Render("Warning:")
for _, w := range loaded.Warnings {
_, _ = fmt.Fprintf(cmd.ErrOrStderr(), "%s %s\n", warning, w)
}
}
// Project skills are listed for the current repository; outside
// one, their folders are unknown.
var repoRoot string
if scope == skills.ScopeProject {
repoRoot, _ = skills.GetRepoRoot()
}
return skills.NewListResult(loaded, scope, repoRoot), nil
}, text.SkillTables); err != nil {
return err
} else if nonInteractive {
return nil
}

// Push TUI view onto the stack.
// We push directly (not via AddToStackFunc) because skills are
// purely local — there's no CLI command string to copy.
Expand All @@ -42,11 +84,11 @@ Use --scope to filter by installation scope (user or project).`,
Breadcrumb: "List Skills",
})
return nil
},
}

return cmd
}

func init() {
skillsCmd.AddCommand(skillsListCmd)
skillsListCmd.Flags().String("scope", "", "Filter skills by installation scope (user or project)")
setFlagPlaceholder(skillsListCmd.Flags(), "scope", "SCOPE")
skillsCmd.AddCommand(newSkillsListCmd(skills.LoadOrRebuildState))
}
Loading