Skip to content

Commit d961de4

Browse files
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>
1 parent 8498bdf commit d961de4

2 files changed

Lines changed: 35 additions & 12 deletions

File tree

pkg/cmd/skills/install/install.go

Lines changed: 12 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -391,7 +391,7 @@ func installRun(opts *InstallOptions) error {
391391
}
392392

393393
printFileTree(opts.IO.ErrOut, cs, result.Dir, result.Installed)
394-
printReviewHint(opts.IO.ErrOut, cs, repoSource, resolved.SHA, result.Installed)
394+
printReviewHint(opts.IO.ErrOut, cs, repoSource, resolved.SHA, result.Installed, opts.AllowHiddenDirs)
395395
printHostHints(opts.IO.ErrOut, cs, plan.hosts, result.Installed, result.Dir, gitRoot)
396396
}
397397

@@ -536,7 +536,7 @@ func runLocalInstall(opts *InstallOptions) error {
536536
}
537537

538538
printFileTree(opts.IO.ErrOut, cs, result.Dir, result.Installed)
539-
printReviewHint(opts.IO.ErrOut, cs, "", "", result.Installed)
539+
printReviewHint(opts.IO.ErrOut, cs, "", "", result.Installed, false)
540540
printHostHints(opts.IO.ErrOut, cs, plan.hosts, result.Installed, result.Dir, gitRoot)
541541
}
542542

@@ -1118,8 +1118,10 @@ func printPreInstallDisclaimer(w io.Writer, cs *iostreams.ColorScheme) {
11181118

11191119
// printReviewHint warns the user to review installed skills and suggests preview commands.
11201120
// When sha is non-empty the suggested commands include @SHA so the user previews
1121-
// exactly the version that was installed.
1122-
func printReviewHint(w io.Writer, cs *iostreams.ColorScheme, repo, sha string, skillNames []string) {
1121+
// exactly the version that was installed. When allowHiddenDirs is true, the
1122+
// suggested commands include --allow-hidden-dirs so previewing hidden-dir
1123+
// skills works without an extra manual step.
1124+
func printReviewHint(w io.Writer, cs *iostreams.ColorScheme, repo, sha string, skillNames []string, allowHiddenDirs bool) {
11231125
if len(skillNames) == 0 {
11241126
return
11251127
}
@@ -1130,11 +1132,15 @@ func printReviewHint(w io.Writer, cs *iostreams.ColorScheme, repo, sha string, s
11301132
}
11311133
fmt.Fprintln(w, " Review installed content before use:")
11321134
fmt.Fprintln(w)
1135+
hiddenFlag := ""
1136+
if allowHiddenDirs {
1137+
hiddenFlag = " --allow-hidden-dirs"
1138+
}
11331139
for _, name := range skillNames {
11341140
if sha != "" {
1135-
fmt.Fprintf(w, " gh skill preview %s %s@%s\n", repo, name, sha)
1141+
fmt.Fprintf(w, " gh skill preview %s %s@%s%s\n", repo, name, sha, hiddenFlag)
11361142
} else {
1137-
fmt.Fprintf(w, " gh skill preview %s %s\n", repo, name)
1143+
fmt.Fprintf(w, " gh skill preview %s %s%s\n", repo, name, hiddenFlag)
11381144
}
11391145
}
11401146
fmt.Fprintln(w)

pkg/cmd/skills/install/install_test.go

Lines changed: 23 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -2141,11 +2141,12 @@ func Test_isSkillPath(t *testing.T) {
21412141

21422142
func Test_printReviewHint(t *testing.T) {
21432143
tests := []struct {
2144-
name string
2145-
repo string
2146-
sha string
2147-
skillNames []string
2148-
wantOutput string
2144+
name string
2145+
repo string
2146+
sha string
2147+
skillNames []string
2148+
allowHiddenDirs bool
2149+
wantOutput string
21492150
}{
21502151
{
21512152
name: "remote install with SHA includes SHA in preview command",
@@ -2182,14 +2183,30 @@ func Test_printReviewHint(t *testing.T) {
21822183
skillNames: []string{},
21832184
wantOutput: "",
21842185
},
2186+
{
2187+
name: "allow-hidden-dirs appends flag to preview command",
2188+
repo: "owner/repo",
2189+
sha: "abc123",
2190+
skillNames: []string{"hidden-skill"},
2191+
allowHiddenDirs: true,
2192+
wantOutput: "gh skill preview owner/repo hidden-skill@abc123 --allow-hidden-dirs",
2193+
},
2194+
{
2195+
name: "allow-hidden-dirs without SHA",
2196+
repo: "owner/repo",
2197+
sha: "",
2198+
skillNames: []string{"hidden-skill"},
2199+
allowHiddenDirs: true,
2200+
wantOutput: "gh skill preview owner/repo hidden-skill --allow-hidden-dirs",
2201+
},
21852202
}
21862203

21872204
for _, tt := range tests {
21882205
t.Run(tt.name, func(t *testing.T) {
21892206
ios, _, _, _ := iostreams.Test()
21902207
cs := ios.ColorScheme()
21912208
var buf strings.Builder
2192-
printReviewHint(&buf, cs, tt.repo, tt.sha, tt.skillNames)
2209+
printReviewHint(&buf, cs, tt.repo, tt.sha, tt.skillNames, tt.allowHiddenDirs)
21932210
if tt.wantOutput == "" {
21942211
assert.Empty(t, buf.String())
21952212
} else {

0 commit comments

Comments
 (0)