Commit f071e74
feat(skills): add
* feat(skills): add `azd ai skill` command group (preview)
Introduces a new standalone `azure.ai.skills` extension that exposes
`azd ai skill create | update | show | list | download | delete` for
managing Foundry Skills from any directory.
Implements the design in PR #8204 / issue #8142:
- New extension under `cli/azd/extensions/azure.ai.skills` (namespace
`ai.skill`, id `azure.ai.skills`, version `0.0.1-preview`).
- Typed Foundry Skills data-plane client in `internal/pkg/skill_api`
with SKILL.md YAML front matter parser and two-phase safe gzip-tar
extractor (zip-slip guard, no symlinks / hard links, 10,000-entry /
512 MB caps, staging + atomic copy, `--force` for collisions).
- Three mutually exclusive `create` modes: inline (`--description` +
`--instructions`), `--file SKILL.md` (parsed locally), and
`--file *.tar.gz` / `*.tgz` (streamed as `application/gzip` to
`POST /skills:import`). `--force` does delete-then-create.
- `update` accepts inline flags or `--file *.md` only; gzip is
rejected with a structured suggestion to use `create --force`.
- `download` extracts by default into `./.agents/skills/<name>/` and
supports `--raw` to write the unmodified archive.
- `delete` confirms by default; `--force` skips, and `--no-prompt`
without `--force` errors. Interactive `n` returns exit 0.
- Endpoint resolution shares the 5-level cascade with `azure.ai.agents`
via a read-only fallback to `extensions.ai-agents.project.context.endpoint`
when the new `extensions.ai-skills.project.context.endpoint` key is
unset.
- Bearer scope `https://ai.azure.com/.default`, `Foundry-Features:
Skills=V1Preview` header, API version `2025-11-15-preview`. Debug
log file `azd-ai-skills-<date>.log`. `IncludeBody` opt-out on the
HTTP pipeline until a sanitizer for `description` / `instructions`
lands.
- Skill name regex aligned with `agent_yaml.ValidateAgentName`:
`^[a-zA-Z0-9]([a-zA-Z0-9-]{0,61}[a-zA-Z0-9])?\$`.
Closes #8142.
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
* fix(azure.ai.skills): endpoint scheme validation + symlink escape in SafeExtract
P1 - Endpoint validation (Finding 1):
- Add validateEndpoint() to endpoint.go that rejects non-https URLs and
empty hosts before sending Azure bearer tokens to any resolved endpoint.
- Called at all five resolution levels (flag, azd env, global config x2,
host env var) so misconfigured endpoints fail with a clear message rather
than an opaque SDK error.
- Host-suffix validation intentionally deferred to HTTP layer per design.
- Add TestResolveProjectEndpoint_InvalidScheme covering http/ftp/no-scheme/empty-host cases.
P1 - Symlink escape in SafeExtract (Finding 2):
- archive.go copy phase was vulnerable: if OutputDir contained a pre-existing
symlink to a directory outside OutputDir, MkdirAll + copyFile would follow
it silently, writing extracted files outside the intended destination.
- Fix: resolve OutputDir with EvalSymlinks once; before each copyFile resolve
the destination directory and assert it is under the real output dir.
- Add isUnder() helper for path containment check.
- Add TestSafeExtract_RejectsSymlinkParentEscape (skipped on Windows).
* fix(skills): use api-version=v1 for skills surface
The Skills data-plane lives under api-version=v1; the preview opt-in is
communicated via the Foundry-Features: Skills=V1Preview header. Using
2025-11-15-preview as the api-version returns 400 UnsupportedApiVersion.
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
* fix(skills): pre-check has_blob before download for clearer error
Skills created from inline JSON or SKILL.md have no downloadable
package; the server returns an opaque 404 'does not have an associated
package'. Pre-flight Get the skill so the download command can return a
structured CodeSkillNoPackage validation error with an actionable
suggestion.
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
* fix(skills): switch from gzip+tar to ZIP for package upload/download
The live Foundry Skills service implements POST /skills:import and
GET /skills/{name}:download with application/zip, not application/gzip
as the upstream TypeSpec declares. Verified via 415 Unsupported Media
Type on gzip uploads. Public docs confirm:
https://learn.microsoft.com/azure/foundry/agents/how-to/tools/skills
Changes:
- skill_api: replace archive/tar+compress/gzip with archive/zip
- skill_api: Download now returns []byte (archive/zip needs io.ReaderAt)
- skill_api: rename ContentTypeGzip -> ContentTypeZip, ErrInvalidGzip ->
ErrInvalidZip
- cmd: accept '.zip' for --file; reject '.tar.gz'/'.tgz'
- cmd: writeRaw now writes '<name>.zip'
- tests: rewrite archive_test.go and archive_peek_test.go for ZIP
- docs (AGENTS.md, README.md, CHANGELOG.md): s/gzip,tar.gz/zip/g
The design spec (PR #8204) will need a follow-up to match.
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
* fix(skills): auto-detect ZIP vs gzip on download (service is asymmetric)
The Foundry Skills surface is asymmetric on archive format:
- POST /skills:import requires application/zip (gzip yields 415)
- GET /skills/{name}:download returns application/gzip
Make SafeExtract sniff magic bytes (PK or 1f 8b) and dispatch to either
the zip or the gzip+tar handler. Download() now accepts both
Content-Type values. The raw download filename uses .zip or .tar.gz
based on the detected format.
Also:
- Add DetectArchiveFormat() public helper for callers that need the
format (e.g. the --raw filename picker).
- Add gitignore for local test artifacts (zips, tar.gz, debug logs).
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
* refactor(skills): trim unnecessary comments and doc blocks
Remove restating-the-code comments, narrative section headers, and
verbose struct-field docs. Keep design-rationale notes (TypeSpec/docs
mismatch on archive format, --force destructive sequence, defensive
path validation) and important safety annotations.
Net: -396 lines of comments, no behavior change.
* fix(azure.ai.skills): drop unused scanner, stream archive peek, reject symlinked copy destinations, use errors.AsType
* fix(skills): address PR feedback on download/update help text
- skill_download: drop 're-create with create --force' hint from the no-package error; users downloading the skill don't have it locally to re-create.
- skill_update: in 'update' long help, route ZIP package updates to 'create --force' and call out that skills are not versioned so it's a destructive (delete-then-recreate) path.
* fix(skills): restore context.go and metadata.go; rename skill_context.go
Restore the original context.go and metadata.go files that were deleted, to respect the existing template structure. Rename skill_context.go to skill_client.go to avoid naming overlap with the restored context command.
* test(skills): cover archive ext, extract error mapping, delete preflight, exterrors
Add unit tests for previously uncovered pure-logic helpers:
- cmd/skill_download_test.go: archiveExtension format mapping, classifyExtractError sentinel-to-LocalError translation (unsafe/limit/collision/invalid + pass-through), and downloadAction.Run name validation short-circuit.
- cmd/skill_delete_test.go: deleteAction.Run rejects invalid names early and surfaces CodeMissingForceFlag when --no-prompt is set without --force.
- cmd/skill_validate_test.go: extend TestIsNotFound to cover real *azcore.ResponseError (404 vs 500, wrapped).
- exterrors/errors_test.go: validation/dependency/auth factories and ServiceFromAzure (wraps *azcore.ResponseError, pass-through, nil); package now at 100% coverage.
* fix(skills): use slices.Contains for traversal segment check
go fix -diff was reporting two conflicting suggestions on the same loop (slicescontains and stringsseq), causing the analyzer to exit non-zero. With bash -e in the lint-go workflow that non-zero exit short-circuited the script, breaking CI even though there was no real diff to print. Replacing the manual loop with slices.Contains resolves the conflict so go fix -diff exits 0.
* fix(skills): address PR feedback - bugs, security hardening, and tests
Co-authored-by: wbreza <6540159+wbreza@users.noreply.github.com>
* feat(skills): materialize SKILL.md for blob-less downloads
Address PR #8224 review feedback from @therealjohn: `azd ai skill
download` previously errored when a skill had no uploaded archive
(`!hasBlob`). The expected behavior is for `download` to always
produce a file on disk for a single skill.
When the skill has no archive blob, materialize a `SKILL.md` file
into --output-dir from the metadata returned by `GET /skills/{name}`
(name, description, metadata, instructions). The existing archive
path is unchanged. `--raw` is rejected for blob-less skills since
there is no archive to write.
- Add `Instructions` field to the `Skill` model so it round-trips
through the wire decode.
- Add `MarshalSkillMd` with stable metadata ordering and a
round-trip test.
- Remove the now-unused `CodeSkillNoPackage` error code.
* refactor(skills): rename skill_client.go to skill_context.go
Address PR #8224 review feedback from @trangevi: the file contains
the `skillContext` struct and `resolveSkillContext` helper, so
`skill_context.go` is a more descriptive name than `skill_client.go`.
The existing `context.go` template command is unaffected — Go only
requires file names within a package to be unique, which they are.
* refactor(skills): align with versioned Skills API spec
Update the azure.ai.skills extension to the versioned Skills API
introduced in azure-rest-api-specs#43283.
API surface changes:
- Skill: { id, name, description, default_version, latest_version, created_at }
(no more inline instructions/metadata/has_blob on the skill itself).
- SkillVersion / SkillInlineContent: new types backing the new
POST /skills/{name}/versions create endpoint (JSON or multipart).
- Routes:
- create : POST /skills/{name}/versions (was POST /skills, POST /skills:import)
- update : POST /skills/{name}/versions for new default version,
POST /skills/{name} for repoint via --set-default-version
(was POST /skills/{name} with full payload)
- delete : DELETE /skills/{name} (response now includes id)
- list : GET /skills (envelope unchanged)
- show : GET /skills/{name} (envelope changed)
- download: GET /skills/{name}/content (was /skills/{name}:download);
new --version flag → /skills/{name}/versions/{version}/content
- Name validation: lowercase-only, ^[a-z0-9]([a-z0-9-]*[a-z0-9])?\$, max 64
(agentskills.io spec via SkillName scalar).
- Preview opt-in (Foundry-Features: Skills=V1Preview) and api-version=v1
remain unchanged.
CLI surface preserved: create / update / show / list / download / delete.
Inline + SKILL.md modes wrap content in inline_content JSON; ZIP create uses
multipart/form-data with a single files[] part. Update --file .zip is still
rejected with a pointer to create --force.
Drop the inline-skill → SKILL.md materialization fallback in download
(MarshalSkillMd) since the server always returns application/zip now.
* fix(skills): address PR review findings
- CHANGELOG: remove duplicated # Release History header block.
- ci-build.ps1: read version.txt from the extension directory; the
parent `cli/azd/extensions/version.txt` does not exist, so the
default `Get-Content` call would fail when `-Version` is not
passed explicitly.
- skill_create: extend `--force` name-mismatch refusal to SKILL.md
inputs. Previously only ZIP packages were peeked before the
destructive delete; a typo with `--file SKILL.md --force` could
delete an unrelated skill, then warn after the fact. Now both
modes share a `verifyFileNameMatches` pre-check.
- skill_api/client: cap `downloadContent` at 512 MiB on the wire
to bound memory before extraction enforces its own uncompressed
cap. Fast-fails on `Content-Length` and also bounds streaming
reads via `io.LimitReader` so a malicious or runaway server
cannot exhaust process memory.
- Tests: cover SKILL.md `--force` mismatch, `--force` allow on
no-name SKILL.md, inline mode bypass, and three new client-level
cases (oversize Content-Length, oversize streaming body,
acceptance at the limit).
---------
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Co-authored-by: copilot-swe-agent[bot] <198982749+Copilot@users.noreply.github.com>
Co-authored-by: wbreza <6540159+wbreza@users.noreply.github.com>azd ai skill command group (#8224)1 parent b429308 commit f071e74
46 files changed
Lines changed: 4749 additions & 53 deletions
File tree
- cli/azd/extensions/azure.ai.skills
- internal
- cmd
- exterrors
- pkg/skill_api
- version
Some content is hidden
Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
| 1 | + | |
| 2 | + | |
| 3 | + | |
| 4 | + | |
| 5 | + | |
| 6 | + | |
| 7 | + | |
| 8 | + | |
| 9 | + | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
| 1 | + | |
| 2 | + | |
| 3 | + | |
| 4 | + | |
| 5 | + | |
| 6 | + | |
| 7 | + | |
| 8 | + | |
| 9 | + | |
| 10 | + | |
| 11 | + | |
| 12 | + | |
| 13 | + | |
| 14 | + | |
| 15 | + | |
| 16 | + | |
| 17 | + | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
| 1 | + | |
| 2 | + | |
| 3 | + | |
| 4 | + | |
| 5 | + | |
| 6 | + | |
| 7 | + | |
| 8 | + | |
| 9 | + | |
| 10 | + | |
| 11 | + | |
| 12 | + | |
| 13 | + | |
| 14 | + | |
| 15 | + | |
| 16 | + | |
| 17 | + | |
| 18 | + | |
| 19 | + | |
| 20 | + | |
| 21 | + | |
| 22 | + | |
| 23 | + | |
| 24 | + | |
| 25 | + | |
| 26 | + | |
| 27 | + | |
| 28 | + | |
| 29 | + | |
| 30 | + | |
| 31 | + | |
| 32 | + | |
| 33 | + | |
| 34 | + | |
| 35 | + | |
| 36 | + | |
| 37 | + | |
| 38 | + | |
| 39 | + | |
| 40 | + | |
| 41 | + | |
| 42 | + | |
| 43 | + | |
| 44 | + | |
| 45 | + | |
| 46 | + | |
| 47 | + | |
| 48 | + | |
| 49 | + | |
| 50 | + | |
| 51 | + | |
| 52 | + | |
| 53 | + | |
| 54 | + | |
| 55 | + | |
| 56 | + | |
| 57 | + | |
| 58 | + | |
| 59 | + | |
| 60 | + | |
| 61 | + | |
| 62 | + | |
| 63 | + | |
| 64 | + | |
| 65 | + | |
| 66 | + | |
| 67 | + | |
| 68 | + | |
| 69 | + | |
| 70 | + | |
| 71 | + | |
| 72 | + | |
| 73 | + | |
| 74 | + | |
| 75 | + | |
| 76 | + | |
| 77 | + | |
| 78 | + | |
| 79 | + | |
| 80 | + | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
1 | 1 | | |
2 | 2 | | |
3 | | - | |
| 3 | + | |
| 4 | + | |
| 5 | + | |
| 6 | + | |
| 7 | + | |
| 8 | + | |
| 9 | + | |
| 10 | + | |
| 11 | + | |
| 12 | + | |
| 13 | + | |
| 14 | + | |
| 15 | + | |
| 16 | + | |
| 17 | + | |
| 18 | + | |
| 19 | + | |
| 20 | + | |
| 21 | + | |
| 22 | + | |
| 23 | + | |
| 24 | + | |
| 25 | + | |
| 26 | + | |
| 27 | + | |
| 28 | + | |
| 29 | + | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
1 | | - | |
| 1 | + | |
2 | 2 | | |
3 | | - | |
| 3 | + | |
| 4 | + | |
| 5 | + | |
| 6 | + | |
| 7 | + | |
| 8 | + | |
| 9 | + | |
| 10 | + | |
| 11 | + | |
| 12 | + | |
| 13 | + | |
| 14 | + | |
| 15 | + | |
| 16 | + | |
| 17 | + | |
| 18 | + | |
| 19 | + | |
| 20 | + | |
| 21 | + | |
| 22 | + | |
| 23 | + | |
| 24 | + | |
| 25 | + | |
| 26 | + | |
| 27 | + | |
| 28 | + | |
| 29 | + | |
| 30 | + | |
| 31 | + | |
| 32 | + | |
| 33 | + | |
| 34 | + | |
| 35 | + | |
| 36 | + | |
| 37 | + | |
| 38 | + | |
| 39 | + | |
| 40 | + | |
| 41 | + | |
| 42 | + | |
| 43 | + | |
| 44 | + | |
| 45 | + | |
| 46 | + | |
| 47 | + | |
| 48 | + | |
| 49 | + | |
| 50 | + | |
| 51 | + | |
| 52 | + | |
| 53 | + | |
| 54 | + | |
| 55 | + | |
| 56 | + | |
| 57 | + | |
| 58 | + | |
| 59 | + | |
| 60 | + | |
| 61 | + | |
| 62 | + | |
| 63 | + | |
| 64 | + | |
| 65 | + | |
| 66 | + | |
| 67 | + | |
| 68 | + | |
| 69 | + | |
| 70 | + | |
| 71 | + | |
| 72 | + | |
| 73 | + | |
| 74 | + | |
| 75 | + | |
| 76 | + | |
| 77 | + | |
| 78 | + | |
| 79 | + | |
| 80 | + | |
| 81 | + | |
| 82 | + | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
41 | 41 | | |
42 | 42 | | |
43 | 43 | | |
44 | | - | |
| 44 | + | |
45 | 45 | | |
46 | 46 | | |
47 | 47 | | |
| |||
65 | 65 | | |
66 | 66 | | |
67 | 67 | | |
68 | | - | |
| 68 | + | |
69 | 69 | | |
70 | 70 | | |
71 | 71 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
33 | 33 | | |
34 | 34 | | |
35 | 35 | | |
36 | | - | |
| 36 | + | |
37 | 37 | | |
38 | 38 | | |
39 | 39 | | |
| |||
53 | 53 | | |
54 | 54 | | |
55 | 55 | | |
56 | | - | |
| 56 | + | |
57 | 57 | | |
58 | 58 | | |
59 | 59 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
6 | 6 | | |
7 | 7 | | |
8 | 8 | | |
9 | | - | |
10 | 9 | | |
11 | 10 | | |
12 | 11 | | |
| |||
19 | 18 | | |
20 | 19 | | |
21 | 20 | | |
| 21 | + | |
| 22 | + | |
| 23 | + | |
| 24 | + | |
22 | 25 | | |
| 26 | + | |
| 27 | + | |
| 28 | + | |
| 29 | + | |
| 30 | + | |
| 31 | + | |
23 | 32 | | |
24 | 33 | | |
25 | 34 | | |
26 | 35 | | |
27 | 36 | | |
28 | 37 | | |
29 | 38 | | |
| 39 | + | |
| 40 | + | |
| 41 | + | |
| 42 | + | |
30 | 43 | | |
31 | 44 | | |
32 | | - | |
| 45 | + | |
| 46 | + | |
| 47 | + | |
| 48 | + | |
| 49 | + | |
| 50 | + | |
33 | 51 | | |
34 | 52 | | |
35 | 53 | | |
36 | 54 | | |
37 | 55 | | |
38 | 56 | | |
39 | 57 | | |
| 58 | + | |
| 59 | + | |
| 60 | + | |
| 61 | + | |
| 62 | + | |
| 63 | + | |
| 64 | + | |
40 | 65 | | |
41 | 66 | | |
42 | 67 | | |
| |||
57 | 82 | | |
58 | 83 | | |
59 | 84 | | |
| 85 | + | |
60 | 86 | | |
61 | 87 | | |
| 88 | + | |
| 89 | + | |
62 | 90 | | |
63 | 91 | | |
64 | 92 | | |
65 | 93 | | |
66 | 94 | | |
| 95 | + | |
67 | 96 | | |
68 | 97 | | |
69 | 98 | | |
| |||
75 | 104 | | |
76 | 105 | | |
77 | 106 | | |
| 107 | + | |
| 108 | + | |
78 | 109 | | |
79 | 110 | | |
80 | 111 | | |
| |||
87 | 118 | | |
88 | 119 | | |
89 | 120 | | |
| 121 | + | |
90 | 122 | | |
91 | 123 | | |
92 | 124 | | |
| |||
97 | 129 | | |
98 | 130 | | |
99 | 131 | | |
| 132 | + | |
100 | 133 | | |
101 | 134 | | |
102 | 135 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
1 | 1 | | |
2 | | - | |
| 2 | + | |
| 3 | + | |
| 4 | + | |
| 5 | + | |
| 6 | + | |
| 7 | + | |
| 8 | + | |
| 9 | + | |
| 10 | + | |
| 11 | + | |
| 12 | + | |
| 13 | + | |
| 14 | + | |
| 15 | + | |
| 16 | + | |
0 commit comments