Skip to content

Commit 4b7437a

Browse files
committed
feat(agent): Implement a skill for automated batch manifest deletion
Signed-off-by: ❤是纱雾酱哟~ <49941141+Dragon1573@users.noreply.github.com>
1 parent aa1622d commit 4b7437a

3 files changed

Lines changed: 107 additions & 0 deletions

File tree

Lines changed: 56 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,56 @@
1+
---
2+
name: winget-removal
3+
description: Use AI Agents to remove a group of WinGet Manifests in batch
4+
---
5+
6+
# winget-removal
7+
8+
Instructions for the agent to follow when this skill is activated.
9+
10+
## When to use
11+
12+
When user ask for removing a (group of) WinGet manifests, the skill should be automatically called for performing the batch removal.
13+
14+
## Prerequisites
15+
16+
1. Make sure if `winget.exe` is installed on user's device.
17+
2. Since this repository is huge and full of tiny YAML files, _Sparse Checkout_ feature of Git might enabled. Detect this by checking Git repository-level and global-level settings.
18+
3. If the _Sparse Checkout_ is enabled. Make sure manifest files are available under `manifests` folder (maybe stored in recursive sub-folders) before invoking the removal script.
19+
- If those manifests are already available on disk, **DO NOT EDIT** sparse checkout folder list.
20+
- If those manifests aren't available to you, you're permitted to edit `.git/info/sparse-checkout` folder list relative to the repository root folder.
21+
- After any changes of the list, perform `git sparse-checkout reapply` to apply the changes.
22+
23+
## Instructions
24+
25+
1. Inspect package identifier of package name from user's prompt, as `<keyword>` here.
26+
3. Get all available versions via `winget.exe search -s winget <keyword>`
27+
- If user explicitly say it's a package identifier, first try adding `--id` switch before `<keyword>` for searching.
28+
- For above sub-rules failed, or you get an empty response, try without adding extra switches.
29+
- If searched package identifier **ISN'T EXACTLY MATCH** what was been inferred by user, pause and ask for user's clarification.
30+
4. Check which version(s) user want to remove.
31+
1. If he/she didn't explicitly mentioned, pause here and ask for clear instructions. **DO NOT ACT WITHOUT KNOWING EXPLICITLY VERSION RANGE!**
32+
2. If user provide a fuzzy natural language "version range", try map it to exact array of versions.
33+
5. Invoke `Remove-Package.ps1` for actual removal.
34+
- The PowerShell script is stored at `./templates/Remove-Package.ps1`, **relative to this Markdown file**.
35+
- Pass `-PackageIdentifier` string for telling with package to remove.
36+
- Pass `-Versions` array for telling exact versions to remove.
37+
- Pass `-IssueId` integer to link the pull request to a known issue.
38+
- Pass `-Assistant` with AI agent specific attribution.
39+
40+
## AI agent specific attribution guidelines
41+
42+
> ### Attribution
43+
>
44+
> When AI tools contribute to the repository, proper attribution helps track the evolving role of AI in the manifest maintenance process. Contributions should include an `Assisted-by` tag in the following format:
45+
>
46+
> ```txt
47+
> Assisted-by: AGENT_NAME:MODEL_VERSION [TOOL1] [TOOL2]
48+
> ```
49+
>
50+
> Where:
51+
>
52+
> - `AGENT_NAME` is the name of the AI tool or framework
53+
> - `MODEL_VERSION` is the specific model version used
54+
> - `[TOOL1] [TOOL2]` are optional specialized analysis tools used (e.g., `Komac`, `Sundry`, `WinGetCreate`, `YamlCreate`)
55+
>
56+
> Basic tools (`git`, editors) **SHOULD NOT** be listed.
Lines changed: 50 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,50 @@
1+
[CmdletBinding()]
2+
param (
3+
[Parameter(Mandatory = $true)]
4+
[string]
5+
$PackageIdentifier,
6+
[Parameter()]
7+
[string[]]
8+
$Versions,
9+
[Parameter(Mandatory = $true)]
10+
[int]
11+
$IssueId,
12+
[Parameter()]
13+
[string]
14+
$AssistantFooter
15+
)
16+
17+
foreach ($v in $Versions) {
18+
$branchName = "issues/$IssueId/$($v -creplace " ", "-")/drop"
19+
$title = "Remove version: $PackageIdentifier version $v"
20+
$body = @"
21+
## ✅ Checklist
22+
23+
- [x] Signed the [Contributor License Agreement](https://cla.opensource.microsoft.com)
24+
- [x] Linked to an issue (if applicable)
25+
- Resolves #$IssueId
26+
27+
## 📦 Manifest Checklist
28+
29+
- [x] Checked that there aren't other open [pull requests](https://github.com/microsoft/winget-pkgs/pulls) for the same manifest update/change
30+
- [x] This PR only modifies one (1) manifest
31+
- [x] It's about manifest removal
32+
33+
"@
34+
35+
# 完成 Git Commit 提交与推送
36+
git.exe switch --create $branchName --no-track "upstream/master"
37+
git.exe rm -r --sparse "manifests/$($PackageIdentifier[0].ToString().ToLower())/$($PackageIdentifier -creplace "\.", "/")/$v"
38+
if ($AssistantFooter -ne "") {
39+
$messages = $title + "`n`n" + $AssistantFooter
40+
}
41+
else {
42+
$messages = $title
43+
}
44+
git.exe commit -vsS -m $messages
45+
git.exe push --progress --set-upstream origin $branchName
46+
gh.exe pr create --no-maintainer-edit --title $title --body $body
47+
git.exe switch master
48+
git.exe branch -d $branchName
49+
Write-Host "----- Above Task Done -----"
50+
}

.gemini

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
.agent

0 commit comments

Comments
 (0)