fix(skills): accept .zip and directory inputs for skill update --file#8509
Open
huimiu wants to merge 1 commit into
Open
fix(skills): accept .zip and directory inputs for skill update --file#8509huimiu wants to merge 1 commit into
huimiu wants to merge 1 commit into
Conversation
…--file` (#8489) `azd ai skill update --file` now accepts the same three input shapes as `azd ai skill create --file`: a single SKILL.md, a .zip archive, or a directory whose root contains SKILL.md. Previously update only accepted .md and rejected .zip / directories with a pointer to `create --force`, which is destructive (deletes the skill and every prior version). Updates create a new immutable version via POST /skills/{name}/versions and promote it to default_version. Prior versions are preserved. - internal/cmd/skill_update.go: add selectUpdateMode + updateMode enum mirroring selectCreateMode; add runFilePackage and runFileDirectory on updateAction that wrap errors with OpUpdateSkill; add printUpdateResult helper that emits only the version JSON in outputJSON mode (no human text on JSON paths); refresh long-help and --file description for the three input shapes. - internal/cmd/skill_update_test.go: drop obsolete .zip / directory rejection tests; add selectUpdateMode routing tests for .zip, directory, .md, inline, set-default, conflict, missing path; add DirectoryWithoutSkillMd and PackageFileMissing preflight tests calling the run methods with a nil client (the preflight returns before any network call). - internal/cmd/skill_validate_test.go: replace RejectsZipFile with AcceptsZipFile asserting .zip routes to updateModeFilePackage. - README.md, AGENTS.md: refresh update file-handling docs. Fixes #8489
📋 Prioritization NoteThanks for the contribution! The linked issue isn't in the current milestone yet. |
Contributor
There was a problem hiding this comment.
Pull request overview
This PR fixes parity between azd ai skill create --file and azd ai skill update --file in the azure.ai.skills extension by allowing update to accept .zip archives and directories (with SKILL.md at the root), making updates non-destructive while preserving version history.
Changes:
- Added
selectUpdateMode+updateModedispatch inskill updateto route inline,.md,.zip, and directory inputs to the appropriate upload path (including directory-to-zip packaging). - Updated/expanded unit tests to validate new routing behavior and preflight error handling for zip/directory inputs.
- Refreshed extension docs/help text to describe the new accepted
--fileshapes and the non-destructive versioning behavior.
Reviewed changes
Copilot reviewed 5 out of 5 changed files in this pull request and generated 6 comments.
Show a summary per file
| File | Description |
|---|---|
cli/azd/extensions/azure.ai.skills/README.md |
Documents update --file examples for .zip and directories and clarifies non-destructive behavior. |
cli/azd/extensions/azure.ai.skills/internal/cmd/skill_validate_test.go |
Updates validation tests to assert .zip/.ZIP inputs are accepted and routed correctly. |
cli/azd/extensions/azure.ai.skills/internal/cmd/skill_update.go |
Implements mode selection + dispatch and adds zip/directory upload support for skill update. |
cli/azd/extensions/azure.ai.skills/internal/cmd/skill_update_test.go |
Adds routing tests and new preflight-only tests for zip/directory update paths. |
cli/azd/extensions/azure.ai.skills/AGENTS.md |
Updates extension-specific guidance to match new update --file supported shapes and semantics. |
skill update --file (#8489)
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
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
Summary
Fixes #8489.
azd ai skill update --filenow accepts the same three input shapes asazd ai skill create --file— a singleSKILL.md, a.ziparchive, or a directory whose root containsSKILL.md— so users no longer have to fall back to the destructivecreate --forceworkaround that deletes the skill and every prior version.create --fileupdate --file(before)update --file(this PR)SKILL.md.ziparchive (SKILL.mdat root)create --force"SKILL.mdat root)create --force"--description/--instructions--set-default-version <ver>Why this matters
The existing rejection forced authors of multi-file skill bundles (folders or zips) into a destructive flow:
create --forcedeletes the skill and all prior versions before recreating it. The whole point ofupdateis to add a new immutable version while preserving history — and the underlyingPOST /skills/{name}/versionsendpoint is already non-destructive, so this was purely a CLI-side validation gap. CI / GitOps flows that builddist/my-skill/and publish a new version now have a non-destructive path.Changes
internal/cmd/skill_update.go— AddupdateModeenum +selectUpdateModemirroringselectCreateMode(detects directory before extension; surfaces stat errors for missing no-extension paths). DispatchRunon the mode:--set-default-version, inline,.md,.zip, and directory each route to a focused helper.runFilePackageandrunFileDirectoryreuseclient.CreateVersionFromZip/skill_api.ArchiveDirectory/skill_api.LocateSkillMdInDirbut wrap errors withexterrors.OpUpdateSkill(notOpCreateSkill). NewprintUpdateResulthelper preserves current JSON behavior — emits only the version envelope inoutputJSONmode (no human text), so callers piping intojqkeep getting valid JSON. Refresh the long help and--filedescription for the three input shapes; drop the "ZIP packages are not accepted here" sentence and the destructivecreate --forcepointer.internal/cmd/skill_update_test.go— DropTestUpdateAction_ZipSuggestionMentionsDestructiveandTestUpdateAction_DirectoryRejectedWithDestructivePointer(the rejection behavior they asserted is the bug). AddselectUpdateModerouting tests for every shape (.zipupper- and lower-case, directory,.md, inline, set-default alone, set-default + content conflict, inline + file conflict, no input, unsupported extension, missing no-extension path surfaces stat error). AddTestUpdateAction_DirectoryWithoutSkillMdFails,TestUpdateAction_PackageFileMissingFails, andTestUpdateAction_PackageFileIsDirectoryFailscalling the run methods with a nil client — the preflight checks fire before any network call, so a nil client is safe and matches the existingTestCreateAction_DirectoryWithoutSkillMdFailspattern.internal/cmd/skill_validate_test.go— ReplaceTestUpdateAction_RejectsZipFilewithTestUpdateAction_AcceptsZipFileasserting both./pkg.zipand./PKG.ZIProute toupdateModeFilePackage. ExtendTestUpdateAction_AcceptsMdFileto also assert routing viaselectUpdateMode.README.md— Add.zipand directory examples to theupdateusage block; replace the "inline-only" paragraph with one that explainsupdatenow accepts the same shapes ascreatenon-destructively.AGENTS.md— Refresh theupdatebullet under "File handling" to reflect the new shapes and the non-destructive append semantics.What this PR deliberately does NOT change
--forceonupdate— the issue explicitly keeps--forcecreate-only, andupdatedoesn't delete anything, so the safety checkcreate --forceneeds (SKILL.mdnamemismatch preflight) doesn't apply here.version.txt/extension.yaml/CHANGELOG.mdbump — percli/azd/extensions/azure.ai.skills/AGENTS.mdline 80, those three files belong to the version-bump PR in the two-PR release convention. A maintainer can pick them up at release prep time.namemismatch preflight onupdate—updatedoesn't delete anything, so a mismatch can't wipe an unrelated skill; the server stores the new version under the positional name regardless. (Out of scope for this fix.)Validation
All clean (
okon every package,0 issuesfromgolangci-lint, nogofmtdiff, nocspellissues on the touched files). The new and modified tests ininternal/cmdpass.