Commit graph

11142 commits

Author SHA1 Message Date
William Martin
18dc5e77f0 Add sampled command telemetry 2026-04-16 21:42:46 +02:00
Babak K. Shandiz
26d2302cb8
Merge pull request #13188 from cli/sammorrowdrums/skills-replace-git-in-publish-tests
Skills: replace real git in publish tests with CommandStubber
2026-04-16 18:30:31 +01:00
Sam Morrow
c5c7d790c5
Update publish_test.go
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
2026-04-16 19:21:35 +02:00
Sam Morrow
bce04e3245
Merge branch 'trunk' into sammorrowdrums/skills-replace-git-in-publish-tests 2026-04-16 19:06:38 +02:00
Copilot
5ae5d1db7f refactor: replace real git with run.CommandStubber in publish tests
Replace all exec.Command("git", ...), initGitRepo, runGitInDir, and
newTestGitClientWithUpstream with run.Stub()/run.CommandStubber stubs.

Changes:
- Remove os/exec and strings imports; add fmt, regexp, internal/run
- Add newTestGitClient(), stubGitRemote(), stubEnsurePushed() helpers
- Remove initGitRepo, runGitInDir, newTestGitClientWithUpstream helpers
- Add cmdStubs field to TestPublishRun table struct
- Convert all test cases to use stub-based git interactions
- Use regexp.QuoteMeta for remote name patterns
- Use %[1]s/%[2]s format args in stubGitRemote
- Initialize git.Client with explicit GitPath to avoid real git resolution
- Rewrite TestEnsurePushed with stub-based tests
- Update TestDetectGitHubRemote_UsesDir and TestPublishRun_DirArgUsesTargetRemote

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
2026-04-16 19:02:53 +02:00
Sam Morrow
d7961f1393
Merge pull request #13185 from cli/sammorrowdrums/skills-post-merge-review-followups
Address post-merge review feedback for skills commands
2026-04-16 18:59:21 +02:00
Sam Morrow
de204f8518
fix: apply review feedback — nil HttpClient, local dedup type
- Return nil instead of real http.Client in unsupported host test
- Move skillResultKey type inside deduplicateResults function scope

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
2026-04-16 18:49:54 +02:00
Kynan Ware
3265170df9
Merge pull request #13175 from cli/kw/first-party-extension-suggestions
Suggest and install official extensions for unknown commands
2026-04-16 10:48:28 -06:00
Kynan Ware
32b8af1017 Remove dispatch after install, install only
Removes post-install extension dispatch to keep the stub focused on
installation. Also removes unused args parameter from the run function.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
2026-04-16 10:38:33 -06:00
Kynan Ware
b8d504cbd9 Rename official extension files and types to stubs
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
2026-04-16 10:34:48 -06:00
Kynan Ware
1d59334964 Replace em-dashes with regular dashes
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
2026-04-16 10:32:00 -06:00
William Martin
81afcd0de0
Merge pull request #13182 from cli/wm/first-party-extension-suggestions
Suggest first party extensions
2026-04-16 18:13:59 +02:00
William Martin
abc2a50b4c Address PR review feedback
- Use cmdutil.DisableAuthCheck instead of raw annotation map
- Convert tests to table-driven format
- Use generic extension name in tests (gh-cool)

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
2026-04-16 18:11:28 +02:00
William Martin
9596f99e56 Add no em dash rule to AGENTS.md
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
2026-04-16 18:09:16 +02:00
Kynan Ware
c8053034e7
Merge pull request #13190 from cli/kw/codeowners-add-code-reviewers
Add @cli/code-reviewers to all CODEOWNERS rules
2026-04-16 09:59:28 -06:00
William Martin
7ad1d7c0a1 Suggest and install official extensions via stub commands
Register hidden stub commands for official GitHub extensions (gh-aw,
gh-stack) that offer to install the extension when invoked. This
replaces the error-string-matching approach from the original PR with
proper cobra commands that:

- Avoid false-positive matches on flag values or post-'--' args
- Eliminate conflicting cobra 'Did you mean?' suggestions
- Properly propagate prompt/install errors for correct exit codes
- Are hidden from help output and shell completions
- Use GroupID "extension" so checkValidExtension allows installing over them
- Are registered after extensions and aliases so both take priority

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
2026-04-16 17:58:37 +02:00
Kynan Ware
d88705ea96 Add @cli/code-reviewers to all CODEOWNERS rules
This ensures that an approval from @cli/code-reviewers can satisfy the
CODEOWNERS requirement for any path, not just the catch-all wildcard.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
2026-04-16 09:47:40 -06:00
Kynan Ware
2fd2fcfe8b
Merge pull request #13189 from cli/kw/skill-reviewers-codeowners
Add cli/skill-reviewers as CODEOWNERS for skills packages
2026-04-16 09:30:28 -06:00
Kynan Ware
a38e81ea5e Add cli/skill-reviewers as CODEOWNERS for skills packages
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
2026-04-16 09:10:00 -06:00
Kynan Ware
97af1a5eb7
Merge pull request #13165 from cli/sm/add-skills-command
Add agent skills command
2026-04-16 09:05:47 -06:00
Sam Morrow
9d00ecc248
style: fix gofmt alignment in publish tests
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
2026-04-16 17:04:12 +02:00
William Martin
a69a5fb2a4
Merge pull request #13187 from cli/sammorrowdrums/fix-skills-acceptance-test
Fix skills-publish-dry-run acceptance test error message mismatch
2026-04-16 16:53:08 +02:00
Sam Morrow
08a0c11d77
fix: update acceptance test to match current error message
The skills-publish-dry-run acceptance test expected 'no skills/ directory
found' on stderr, but the actual error message from discovery is
'no skills found in <dir>'. Update the stderr matcher accordingly.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
2026-04-16 16:37:34 +02:00
Sam Morrow
8b115d2c23
fix: address post-merge review feedback for skills commands
- Remove direct opts.client injection in publish; use HttpClient factory
  pattern (PR #13168 feedback)
- Rename testName to name in discovery test struct (PR #13170 feedback)
- Use typed struct keys for dedup map with case-insensitive comparison
  in deduplicateResults (PR #13170 feedback)
- Simplify remote selection to use Remotes() ordering instead of manual
  origin-first logic (PR #13171 feedback)
- Fix push icon timing: show no icon before push, SuccessIcon after
  success (PR #13171 feedback)

Closes #13184

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
2026-04-16 16:19:59 +02:00
Sam Morrow
1aa19846d4
Merge branch 'trunk' into sm/add-skills-command 2026-04-16 15:56:48 +02:00
Sam Morrow
963a1438a9
Merge pull request #13170 from cli/sammorrowdrums/fix-skills-namespace-dedup
fix: preserve namespace in skills search deduplication
2026-04-16 15:55:41 +02:00
Sam Morrow
29e55fe5b9
refactor: remove redundant nil-client fallback in skills publish (#13168)
Remove the dead code block that silently swallowed errors from
opts.HttpClient() and opts.Config() when creating an API client.
Instead, create the client with proper error propagation inside the
remote-checks block where it is actually needed.

Changes:
- Remove the error-swallowing client == nil fallback (lines 363-376)
- Create the API client inside the remote repo checks block with
  proper error returns from HttpClient() and Config()
- Resolve host from repoInfo first, then fall back to config
- Remove the now-unreachable 'client == nil' early exit before publish

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
2026-04-16 15:52:53 +02:00
Sam Morrow
cf1afc9b88
Merge pull request #13167 from cli/sammorrowdrums/publish-use-shared-discovery
Publish: use shared discovery logic instead of requiring skills/ directory
2026-04-16 15:48:20 +02:00
Sam Morrow
31265d371b
Merge pull request #13171 from cli/sammorrowdrums/skill-publish-unpushed-check
feat(skills): auto-push unpushed commits before publish
2026-04-16 15:47:06 +02:00
Sam Morrow
e559a7cd5b
feat(skills): auto-push unpushed commits before publish
Like gh pr create, skill publish now automatically pushes unpushed
local commits before creating a release. This prevents the footgun
where a release is created against stale remote state when the user
has local commits that haven't been pushed yet.

The ensurePushed function checks for unpushed commits using
git rev-list @{push}..HEAD. If commits exist or the branch has
never been pushed, it pushes automatically and prints a status
message. This matches the CLI's opinionated-defaults philosophy
of doing the right thing by default.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
2026-04-16 15:43:10 +02:00
Sam Morrow
b63f5bfd9a
refactor: use shared discovery logic in publish command
Replace the hardcoded skills/ directory requirement in the publish
command with the shared DiscoverLocalSkills() function used by install
and other commands. This removes the opinionated restriction that skills
must live under a skills/ directory and supports all discovery
conventions:

- skills/*/SKILL.md
- skills/{scope}/*/SKILL.md
- */SKILL.md (root-level)
- plugins/{scope}/skills/*/SKILL.md

All per-skill validation (frontmatter, spec-compliant naming, metadata
stripping, etc.) is preserved.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
2026-04-16 15:38:36 +02:00
Sam Morrow
c5cff0f298
Merge pull request #13183 from cli/babakks/improve-skill-docs
docs(skill): polish skill commadset docs
2026-04-16 15:19:38 +02:00
Babak K. Shandiz
a1eb707e26
fix(skill publish): remove misleading validate alias
Signed-off-by: Babak K. Shandiz <babakks@github.com>
2026-04-16 14:04:29 +01:00
Babak K. Shandiz
3dce81a0d6
docs(skill): improve help docs
Signed-off-by: Babak K. Shandiz <babakks@github.com>
2026-04-16 14:03:54 +01:00
William Martin
ebe0631de2
Merge pull request #13176 from cli/kw/remove-ext-install-auth-check
Disable auth check for `gh extension install`
2026-04-16 12:18:43 +02:00
tommaso-moro
a6e9722ec1 fix skills names in examples 2026-04-16 10:20:24 +01:00
Kynan Ware
3e0305d941 Disable auth check for gh extension install
Allow installing extensions without being authenticated. The install
command can work with public repositories and local directories without
requiring a login, so the auth gate is unnecessary.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
2026-04-15 17:55:45 -06:00
Kynan Ware
75909ed2ba Suggest and install official extensions for unknown commands
When a user runs an unknown command that matches a known official
extension (e.g. `gh stack` or `gh aw`), show an install suggestion.
In interactive TTY sessions, prompt the user to install it on the spot.

The official extension registry is hard-coded in pkg/extensions/.
Current entries are github/gh-aw and github/gh-stack. Teams can add
their extensions via PR. Install suggestions use an explicit github.com
host prefix for GHES compatibility.

Refs github/cli#220

Co-Authored-By: Copilot <223556219+Copilot@users.noreply.github.com>
2026-04-15 17:50:31 -06:00
Sam Morrow
980428c304
Merge pull request #13169 from cli/sammorrowdrums/fix-skills-publish-remote-detection 2026-04-16 01:17:06 +02:00
Sam Morrow
9552d225cc
Update acceptance/testdata/skills/skills-search-noresults.txtar
Co-authored-by: Kynan Ware <47394200+BagToad@users.noreply.github.com>
2026-04-16 00:35:39 +02:00
Sam Morrow
ce3e08169c
Merge pull request #13172 from cli/sammorrowdrums/fix-url-encode-parent-path
URL-encode parentPath in skills discovery API call
2026-04-16 00:16:20 +02:00
Sam Morrow
9f9b93aa6a
URL-encode parentPath in skills discovery API call
The parentPath parameter in the contents API path was not URL-encoded,
which would cause failures when paths contain spaces or other special
characters. Apply url.PathEscape() to parentPath, consistent with
the rest of the file. commitSHA is left unescaped since SHAs are
hex-only and never need encoding.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
2026-04-16 00:06:48 +02:00
Sam Morrow
d4c6d61734
Merge pull request #13173 from cli/sammorrowdrums/disable-auth-check-local-flags
Disable auth check for local-only skill flags
2026-04-15 23:52:26 +02:00
Sam Morrow
f2d978d960
Disable auth check for local-only skill flags
Add cmdutil.DisableAuthCheckFlag for --from-local on install so that
installing from a local directory does not require authentication.
This follows the same pattern used by attestation verify for its
--bundle flag.

The --dry-run flag on publish is intentionally left with auth enabled
because dry-run validation includes remote repository checks (security
settings, tag protection, topics).

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
2026-04-15 23:49:28 +02:00
Sam Morrow
e04dceb3b5
fix: address review feedback on namespace changes
- Keep skillName as bare name in JSON output for backward compat;
  namespace is available as a separate --json field
- Fix Namespace field comment to cover plugin namespaces too
- Trim /SKILL.md from install path arg to match comment
- Rename acceptance test to skills-install-namespaced since it
  tests install disambiguation, not search

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
2026-04-15 23:39:11 +02:00
Sam Morrow
013d531101
chore: remove unused newTestGitClient function
Remove the now-unused newTestGitClient helper that was left behind
after refactoring tests to use initGitRepo directly. This fixes the
golangci-lint 'unused' error in CI.

Co-authored-by: BagToad <47394200+BagToad@users.noreply.github.com>
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
2026-04-15 23:36:25 +02:00
Sam Morrow
92e40eabea
fix: preserve namespace in skills search deduplication
Skills with the same name but different namespaces (e.g.
skills/kynan/commit and skills/will/commit) were being collapsed
into a single search result because extractSkillName discarded the
namespace. This also caused deduplicateByName to cap results
across different namespaces as if they were the same skill.

Changes:
- Add MatchSkillPath to discovery package returning both name and
  namespace (the existing MatchesSkillPath is kept for compat)
- Add Namespace field to skillResult in search
- Fix deduplicateResults to use repo/namespace/name as the dedup key
- Fix deduplicateByName to cap by namespace-qualified name
- Update table, prompt, and JSON output to show qualified names
- Use skill path for install subprocess when namespace is present,
  ensuring unambiguous install of namespaced skills
- Add namespace to --json fields and relevance scoring/filtering
- Add unit tests for namespace dedup, qualified names, and filtering
- Add acceptance test for namespaced skill search and install

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
2026-04-15 23:01:09 +02:00
Sam Morrow
1d5c74a838
fix: use target directory remotes in skills publish
When a directory argument is provided to `gh skill publish`, the remote
detection now correctly uses the target directory's git remotes instead
of the current working directory's remotes.

Previously, `detectGitHubRemote` used the factory-provided git client
which pointed to the CWD. This meant that running
`gh skill publish /path/to/repo-bar` from inside repo-foo would detect
repo-foo's remotes and potentially create the release on the wrong repo.

The fix copies the git client and sets `RepoDir` to the target directory,
matching the pattern already used by `detectMissingRepoDiagnostic` and
`checkInstalledSkillDirs`.

Co-authored-by: BagToad <47394200+BagToad@users.noreply.github.com>
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
2026-04-15 22:56:06 +02:00
Sam Morrow
a6f6ab330f
fix: enforce size cap on first preview file, surface corrupted skills, fail on path traversal
- preview: remove 'fetched > 0' guard so the 512KB size cap applies
  uniformly to all files including the first
- update: return skills with corrupted YAML frontmatter with metadataErr
  set instead of silently dropping them from scan results
- installer: fail installation when a path traversal is detected in
  remote or local skill files instead of silently skipping

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
2026-04-15 16:53:27 +02:00
Sam Morrow
6c7743eaf1
fix: align relevanceScore comments with implementation and fix typo
- Update comment in relevanceScore() from '10 000 points' to '3 000 points'
  to match the actual implementation value of 3_000
- Update corresponding test comment for consistency
- Fix typo: 'swaped' → 'swapped' in formatStars comment

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
2026-04-15 16:41:09 +02:00