fix(skills): include --allow-hidden-dirs in preview hint from install

The review hint printed after `gh skill install --allow-hidden-dirs`
suggests `gh skill preview` commands. Those commands would fail for
hidden-dir skills because preview would filter them out. Pass the
flag through so the suggested commands work as-is.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
This commit is contained in:
sammorrowdrums 2026-04-23 10:23:26 +02:00
parent 8498bdf435
commit d961de44d7
2 changed files with 35 additions and 12 deletions

View file

@ -391,7 +391,7 @@ func installRun(opts *InstallOptions) error {
}
printFileTree(opts.IO.ErrOut, cs, result.Dir, result.Installed)
printReviewHint(opts.IO.ErrOut, cs, repoSource, resolved.SHA, result.Installed)
printReviewHint(opts.IO.ErrOut, cs, repoSource, resolved.SHA, result.Installed, opts.AllowHiddenDirs)
printHostHints(opts.IO.ErrOut, cs, plan.hosts, result.Installed, result.Dir, gitRoot)
}
@ -536,7 +536,7 @@ func runLocalInstall(opts *InstallOptions) error {
}
printFileTree(opts.IO.ErrOut, cs, result.Dir, result.Installed)
printReviewHint(opts.IO.ErrOut, cs, "", "", result.Installed)
printReviewHint(opts.IO.ErrOut, cs, "", "", result.Installed, false)
printHostHints(opts.IO.ErrOut, cs, plan.hosts, result.Installed, result.Dir, gitRoot)
}
@ -1118,8 +1118,10 @@ func printPreInstallDisclaimer(w io.Writer, cs *iostreams.ColorScheme) {
// printReviewHint warns the user to review installed skills and suggests preview commands.
// When sha is non-empty the suggested commands include @SHA so the user previews
// exactly the version that was installed.
func printReviewHint(w io.Writer, cs *iostreams.ColorScheme, repo, sha string, skillNames []string) {
// exactly the version that was installed. When allowHiddenDirs is true, the
// suggested commands include --allow-hidden-dirs so previewing hidden-dir
// skills works without an extra manual step.
func printReviewHint(w io.Writer, cs *iostreams.ColorScheme, repo, sha string, skillNames []string, allowHiddenDirs bool) {
if len(skillNames) == 0 {
return
}
@ -1130,11 +1132,15 @@ func printReviewHint(w io.Writer, cs *iostreams.ColorScheme, repo, sha string, s
}
fmt.Fprintln(w, " Review installed content before use:")
fmt.Fprintln(w)
hiddenFlag := ""
if allowHiddenDirs {
hiddenFlag = " --allow-hidden-dirs"
}
for _, name := range skillNames {
if sha != "" {
fmt.Fprintf(w, " gh skill preview %s %s@%s\n", repo, name, sha)
fmt.Fprintf(w, " gh skill preview %s %s@%s%s\n", repo, name, sha, hiddenFlag)
} else {
fmt.Fprintf(w, " gh skill preview %s %s\n", repo, name)
fmt.Fprintf(w, " gh skill preview %s %s%s\n", repo, name, hiddenFlag)
}
}
fmt.Fprintln(w)

View file

@ -2141,11 +2141,12 @@ func Test_isSkillPath(t *testing.T) {
func Test_printReviewHint(t *testing.T) {
tests := []struct {
name string
repo string
sha string
skillNames []string
wantOutput string
name string
repo string
sha string
skillNames []string
allowHiddenDirs bool
wantOutput string
}{
{
name: "remote install with SHA includes SHA in preview command",
@ -2182,6 +2183,22 @@ func Test_printReviewHint(t *testing.T) {
skillNames: []string{},
wantOutput: "",
},
{
name: "allow-hidden-dirs appends flag to preview command",
repo: "owner/repo",
sha: "abc123",
skillNames: []string{"hidden-skill"},
allowHiddenDirs: true,
wantOutput: "gh skill preview owner/repo hidden-skill@abc123 --allow-hidden-dirs",
},
{
name: "allow-hidden-dirs without SHA",
repo: "owner/repo",
sha: "",
skillNames: []string{"hidden-skill"},
allowHiddenDirs: true,
wantOutput: "gh skill preview owner/repo hidden-skill --allow-hidden-dirs",
},
}
for _, tt := range tests {
@ -2189,7 +2206,7 @@ func Test_printReviewHint(t *testing.T) {
ios, _, _, _ := iostreams.Test()
cs := ios.ColorScheme()
var buf strings.Builder
printReviewHint(&buf, cs, tt.repo, tt.sha, tt.skillNames)
printReviewHint(&buf, cs, tt.repo, tt.sha, tt.skillNames, tt.allowHiddenDirs)
if tt.wantOutput == "" {
assert.Empty(t, buf.String())
} else {