-
Notifications
You must be signed in to change notification settings - Fork 306
feat(skills): add azd ai skill command group
#8224
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Open
huimiu
wants to merge
14
commits into
main
Choose a base branch
from
huimiu/hui-add-skill-command
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
Show all changes
14 commits
Select commit
Hold shift + click to select a range
5004c98
feat(skills): add `azd ai skill` command group (preview)
huimiu 4757f72
fix(azure.ai.skills): endpoint scheme validation + symlink escape in …
huimiu 09a750b
fix(skills): use api-version=v1 for skills surface
huimiu c957348
fix(skills): pre-check has_blob before download for clearer error
huimiu 4237ac1
fix(skills): switch from gzip+tar to ZIP for package upload/download
huimiu 5b20894
fix(skills): auto-detect ZIP vs gzip on download (service is asymmetric)
huimiu 16a3cb3
refactor(skills): trim unnecessary comments and doc blocks
huimiu 6f9e6ea
fix(azure.ai.skills): drop unused scanner, stream archive peek, rejec…
huimiu 3d7bb9a
fix(skills): address PR feedback on download/update help text
huimiu 1b7af85
Merge branch 'main' into huimiu/hui-add-skill-command
huimiu 344f564
fix(skills): restore context.go and metadata.go; rename skill_context.go
huimiu c9801d7
test(skills): cover archive ext, extract error mapping, delete prefli…
huimiu fec6173
fix(skills): use slices.Contains for traversal segment check
huimiu ad851b7
fix(skills): address PR feedback - bugs, security hardening, and tests
Copilot File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,9 @@ | ||
| # Local test artifacts | ||
| SKILL.md | ||
| test-skill/ | ||
| test-min/ | ||
| test-*/ | ||
| *.zip | ||
| *.tar.gz | ||
| azd-ai-skills-*.log | ||
| bin/ |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,17 @@ | ||
| version: "2" | ||
|
|
||
| linters: | ||
| default: none | ||
| enable: | ||
| - gosec | ||
| - lll | ||
| - unused | ||
| - errorlint | ||
| settings: | ||
| lll: | ||
| line-length: 220 | ||
| tab-width: 4 | ||
|
|
||
| formatters: | ||
| enable: | ||
| - gofmt |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,73 @@ | ||
| # Azure AI Skills Extension - Agent Instructions | ||
|
|
||
| Use this file together with `cli/azd/AGENTS.md`. This guide supplements the root azd instructions with the conventions that are specific to this extension. | ||
|
|
||
| ## Overview | ||
|
|
||
| `azure.ai.skills` is a first-party azd extension under `cli/azd/extensions/azure.ai.skills/`. It runs as a separate Go binary and talks to the azd host over gRPC. It exposes the `azd ai skill <verb>` command group for managing Foundry Skills. | ||
|
|
||
| Useful places to start: | ||
|
|
||
| - `internal/cmd/`: Cobra commands and top-level orchestration | ||
| - `internal/pkg/skill_api/`: typed Foundry Skills REST client, models, SKILL.md parser, and safe ZIP extractor | ||
| - `internal/exterrors/`: structured error factories and extension-specific codes | ||
|
|
||
| ## Relationship to `azure.ai.agents` | ||
|
|
||
| This extension is intentionally separate from `azure.ai.agents`. It shares no code symbols but cooperates with it via the global-config endpoint key: | ||
|
|
||
| - This extension writes to `extensions.ai-skills.project.context.endpoint` (none yet — read-only today). | ||
| - This extension reads `extensions.ai-skills.project.context.endpoint` first, then falls back to `extensions.ai-agents.project.context.endpoint` so users who already configured the endpoint via the agents extension are not forced to re-run `set`. | ||
|
|
||
| `AgentCardSkill` (in `azure.ai.agents`) is unrelated to the `Skill` resource managed here and lives in a different Go module. | ||
|
|
||
| ## Build and test | ||
|
|
||
| From `cli/azd/extensions/azure.ai.skills`: | ||
|
|
||
| ```bash | ||
| # Build using developer extension (for local development) | ||
| azd x build | ||
|
|
||
| # Or build using Go directly | ||
| go build | ||
| ``` | ||
|
|
||
| If extension work depends on a new azd core change, plan for two PRs: | ||
|
|
||
| 1. Land the core change in `cli/azd` first. | ||
| 2. Land the extension change after that, updating this module to the newer azd dependency with `go get github.com/azure/azure-dev/cli/azd && go mod tidy`. | ||
|
|
||
| For local development, draft work, or validating both sides together before the core PR is merged, you may temporarily add: | ||
|
|
||
| ```go | ||
| replace github.com/azure/azure-dev/cli/azd => ../../ | ||
| ``` | ||
|
|
||
| That `replace` points this extension at your local `cli/azd` checkout instead of the version in `go.mod`. Do not merge the extension with that `replace` still present. | ||
|
|
||
| ## Error handling | ||
|
|
||
| This extension uses `internal/exterrors` so the azd host can show a useful message, attach an optional suggestion, and emit stable telemetry. See `cli/azd/extensions/azure.ai.agents/AGENTS.md` "Error handling" section for the full conventions — they apply here unchanged. | ||
|
|
||
| Skill-specific error codes live in `internal/exterrors/codes.go`: | ||
|
|
||
| - `CodeInvalidSkillName` — name fails the alphanumeric-with-hyphens regex | ||
| - `CodeInvalidSkillFile` — SKILL.md front matter unparsable, or `--file` extension unsupported | ||
| - `CodeSkillArchiveUnsafe` — `download` rejected an archive entry (zip-slip, symlink, oversized, etc.) | ||
| - `CodeSkillOutputCollision` — `download` would overwrite an existing file without `--force` | ||
|
|
||
| ## Debug logging | ||
|
|
||
| Each `--debug` run writes to `azd-ai-skills-<date>.log` in the current working directory. The `skill_api` client deliberately opts out of `IncludeBody` request/response logging until a sanitizer is in place that redacts user-authored `description` and `instructions` fields. Do not enable body logging without that sanitizer. | ||
|
|
||
| ## File handling | ||
|
|
||
| - `--file` is **not** a manifest. It is read at invocation time only; the CLI does not track or re-read it after the command returns. | ||
| - `create`: accepts `.md` or `.zip`. Mode is inferred from extension; conflicting modes (inline + `--file`) are rejected. | ||
| - `update`: accepts `.md` only. `.zip` is rejected with a structured suggestion to use `create --force`. | ||
| - `download`: writes either an extracted directory (default) or the unmodified ZIP archive (`--raw`). | ||
|
|
||
| ## Release preparation | ||
|
|
||
| Follows the same two-PR convention as `azure.ai.agents`: a version-bump PR that touches only `version.txt`, `extension.yaml`, and `CHANGELOG.md`, followed by a registry-update PR generated by `azd x publish` against the released artifacts. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,3 +1,19 @@ | ||
| # Release History | ||
|
|
||
| ## 0.0.1-preview - Initial Version | ||
| ## 0.0.1-preview (Unreleased) | ||
|
|
||
| - Initial preview release of the `azure.ai.skills` extension. | ||
| - Adds the `azd ai skill` command group with full CRUD over Foundry Skills: | ||
| - `azd ai skill create <name>` — inline (`--description` + `--instructions`), | ||
| SKILL.md file (`--file ./SKILL.md`), or ZIP package (`--file ./skill.zip`). | ||
| - `azd ai skill update <name>` — inline or `--file *.md`. | ||
| - `azd ai skill show <name>` — metadata only. | ||
| - `azd ai skill list` — paginated, supports `--top` and `--orderby`. | ||
| - `azd ai skill download <name>` — extracts to `./.agents/skills/<name>/` by | ||
| default; `--raw` keeps the archive as-is. The downloader auto-detects ZIP | ||
| vs gzip-tar via magic bytes because the Foundry surface is asymmetric: | ||
| uploads require `application/zip`, downloads return `application/gzip`. | ||
| - `azd ai skill delete <name>` — confirmation by default, `--force` to skip. | ||
| - Shares the Foundry project-endpoint resolution cascade with `azure.ai.agents`, | ||
| reading `extensions.ai-skills.project.context.endpoint` first and falling | ||
| back to `extensions.ai-agents.project.context.endpoint`. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,3 +1,75 @@ | ||
| # Foundry Skills | ||
| # Azure Developer CLI (azd) Skills Extension | ||
|
|
||
| Manage Microsoft Foundry Skills from your terminal. (Preview) | ||
| Manage [Microsoft Foundry](https://learn.microsoft.com/azure/ai-services/) **skills** | ||
| (reusable behavioral guidelines an agent can attach at runtime) directly from your | ||
| terminal. | ||
|
|
||
| ## Commands | ||
|
|
||
| ```bash | ||
| azd ai skill create <name> [--description "..." --instructions "..."] | ||
| azd ai skill create <name> --file ./SKILL.md | ||
| azd ai skill create <name> --file ./skill.zip | ||
|
|
||
| azd ai skill update <name> [--description "..."] [--instructions "..."] [--file ./SKILL.md] | ||
| azd ai skill show <name> | ||
| azd ai skill list [--top N] [--orderby <field>] | ||
| azd ai skill download <name> [--output-dir <path>] [--raw] [--force] | ||
| azd ai skill delete <name> [--force] | ||
| ``` | ||
|
|
||
| All commands accept the standard cross-cutting flags: `-p` / `--project-endpoint`, | ||
| `--output table|json`, `--no-prompt`, and `--debug`. | ||
|
|
||
| ## Project endpoint resolution | ||
|
|
||
| The Foundry project endpoint is resolved in this order: | ||
|
|
||
| 1. `-p` / `--project-endpoint` flag on the command. | ||
| 2. Active azd env value `AZURE_AI_PROJECT_ENDPOINT`. | ||
| 3. Global config `extensions.ai-skills.project.context.endpoint` | ||
| (falls back to `extensions.ai-agents.project.context.endpoint` so users who | ||
| configured the endpoint via the agents extension are not forced to re-run `set`). | ||
| 4. Host environment variable `FOUNDRY_PROJECT_ENDPOINT`. | ||
| 5. Structured error with an actionable suggestion. | ||
|
|
||
| ## Local Development | ||
|
|
||
| ### Prerequisites | ||
|
|
||
| 1. **Install developer kit extension** (if not already installed): | ||
|
|
||
| ```bash | ||
| azd ext install microsoft.azd.extensions | ||
| ``` | ||
|
|
||
| ### Building and installing locally | ||
|
|
||
| 1. **Navigate to the extension directory**: | ||
|
|
||
| ```bash | ||
| cd cli/azd/extensions/azure.ai.skills | ||
| ``` | ||
|
|
||
| 2. **Initial setup** (first time only): | ||
|
|
||
| ```bash | ||
| azd x build | ||
| azd x pack | ||
| azd x publish | ||
| ``` | ||
|
|
||
| 3. **Install the extension**: | ||
|
|
||
| ```bash | ||
| azd ext install azure.ai.skills | ||
| ``` | ||
|
|
||
| 4. **For subsequent development** (after initial setup): | ||
|
|
||
| ```bash | ||
| azd x watch | ||
| ``` | ||
|
|
||
| This automatically watches for file changes, rebuilds, and installs updates | ||
| locally. | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,2 +1,13 @@ | ||
| import: ../../.vscode/cspell.yaml | ||
| words: [] | ||
| words: | ||
| # Skill commands | ||
| - azureaiskills | ||
| - exterrors | ||
| - foundry | ||
| - foundrysdk | ||
| - orderby | ||
| - tarball | ||
| - zipslip | ||
| - gzip | ||
| - skill | ||
| - skills |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,14 +1,26 @@ | ||
| # yaml-language-server: $schema=https://raw.githubusercontent.com/Azure/azure-dev/refs/heads/main/cli/azd/extensions/extension.schema.json | ||
| capabilities: | ||
| - custom-commands | ||
| - metadata | ||
| description: Manage Microsoft Foundry Skills from your terminal. (Preview) | ||
| displayName: Foundry Skills (Preview) | ||
| # yaml-language-server: $schema=../extension.schema.json | ||
| id: azure.ai.skills | ||
| language: go | ||
| namespace: ai.skill | ||
| tags: | ||
| - ai | ||
| - skill | ||
| displayName: Foundry skills (Preview) | ||
| description: Manage Microsoft Foundry skills (reusable agent behavioral guidelines) from your terminal. (Preview) | ||
| usage: azd ai skill <command> [options] | ||
| # NOTE: Make sure version.txt is in sync with this version. | ||
| version: 0.0.1-preview | ||
| requiredAzdVersion: ">1.23.13" | ||
| language: go | ||
| capabilities: | ||
| - custom-commands | ||
| - metadata | ||
| tags: | ||
| - ai | ||
| - skill | ||
| examples: | ||
| - name: list | ||
| description: List skills in the current Foundry project. | ||
| usage: azd ai skill list | ||
| - name: create | ||
| description: Create a skill from a SKILL.md file. | ||
| usage: azd ai skill create my-skill --file ./SKILL.md | ||
| - name: download | ||
| description: Download and extract a skill into ./.agents/skills/. | ||
| usage: azd ai skill download my-skill |
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.