-
Notifications
You must be signed in to change notification settings - Fork 3.5k
{Agent} Move X agent skills into repository policy #34033
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
Aditya Pujara (a0x1ab)
wants to merge
6
commits into
Azure:dev
Choose a base branch
from
a0x1ab:a0x1ab/repository-custom-skills
base: dev
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 1 commit
Commits
Show all changes
6 commits
Select commit
Hold shift + click to select a range
1f1196b
Move Azure CLI skills into repository policy
a0x1ab ff35dd6
Remove custom skills README
a0x1ab 29fe438
Fix tester target inference arguments
a0x1ab e940fab
Complete repository-owned agent workflows
a0x1ab 6a09333
Address custom skill review feedback
a0x1ab 7f6b74b
Add license headers to repository skills
a0x1ab 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
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,6 +1,9 @@ | ||
| # Custom skills | ||
|
|
||
| This repository currently uses the approved X Engineering Agent base skill | ||
| library. A repository-owned custom skill must be one Python file containing | ||
| one public top-level function and must be mapped in `.x/x.yml`. Markdown files | ||
| in this directory are documentation and are never executable. | ||
| Each Python file contains one repository-owned public function mapped by | ||
| `.x/x.yml`. Custom skills own Azure CLI target inference, regression policy, | ||
| AAZ source routing, and the CLI-to-Extensions handoff. Authentication, | ||
| sensitive-data checks, repository scoping, and narrow GitHub mutations remain | ||
| in the approved base primitives. Repository directory discovery resolves roots | ||
| and branches from central trusted configuration rather than repository-supplied | ||
| arguments. Markdown files are never executable. |
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,23 @@ | ||
| """Select changed Azure CLI pytest modules.""" | ||
|
|
||
|
|
||
| def changed_test_files(pr_files): | ||
| """Return unique changed test filename stems outside azure-cli-core.""" | ||
| stems = [] | ||
| seen = set() | ||
| for path in pr_files or []: | ||
| normalized = str(path).replace("\\", "/") | ||
| lowered = normalized.casefold() | ||
| name = normalized.rsplit("/", 1)[-1] | ||
| if ( | ||
| "/tests/" not in f"/{lowered}" | ||
| or not name.casefold().startswith("test_") | ||
| or not name.casefold().endswith(".py") | ||
| or "azure-cli-core" in lowered.split("/") | ||
| ): | ||
| continue | ||
| stem = name[:-3] | ||
| if stem not in seen: | ||
| seen.add(stem) | ||
| stems.append(stem) | ||
| return stems |
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,8 @@ | ||
| """Bind generation-source candidate discovery to Azure CLI.""" | ||
|
|
||
|
|
||
| def find_aaz_fork_prs_ready_for_promotion(): | ||
| """Find completed AAZ fork pull requests ready for promotion.""" | ||
| return find_generation_source_fork_prs_ready_for_promotion( | ||
| repository=None, | ||
| ) |
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 @@ | ||
| """Bind promoted generation-source lookup to Azure CLI.""" | ||
|
|
||
|
|
||
| def find_promoted_aaz_source_pr(issue_number): | ||
| """Find the promoted AAZ source pull request for an Agent issue.""" | ||
| return find_promoted_generation_source_pr( | ||
| repository=None, | ||
| issue_number=issue_number, | ||
| ) |
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,66 @@ | ||
| """Evaluate Azure CLI command-module regression coverage.""" | ||
|
|
||
|
|
||
| def get_pr_regression_coverage_summary(pr_number): | ||
| """Find changed command modules without focused tests or recordings.""" | ||
| changes = get_pr_file_changes( | ||
| owner=None, | ||
| repo=None, | ||
| pr_number=pr_number, | ||
| ) | ||
| files = [ | ||
| item.get("filename") | ||
| for item in changes | ||
| if isinstance(item, dict) and item.get("filename") | ||
| ] | ||
| root = "src/azure-cli/azure/cli/command_modules/" | ||
| production_files = [] | ||
| modules = set() | ||
| for path in files: | ||
| normalized = str(path).replace("\\", "/") | ||
| name = normalized.rsplit("/", 1)[-1] | ||
| if ( | ||
| normalized.startswith(root) | ||
| and normalized.endswith(".py") | ||
| and "/tests/" not in normalized | ||
| and name not in {"__init__.py", "_help.py"} | ||
| ): | ||
| production_files.append(normalized) | ||
| remainder = normalized[len(root):] | ||
| module = remainder.split("/", 1)[0].split(".", 1)[0].casefold() | ||
| if module: | ||
| modules.add(module) | ||
|
|
||
| test_files = [] | ||
| recording_files = [] | ||
| covered = set() | ||
| for path in files: | ||
| normalized = str(path).replace("\\", "/") | ||
| if not normalized.startswith(root) or "/tests/" not in normalized: | ||
| continue | ||
| module = ( | ||
| normalized[len(root):] | ||
| .split("/", 1)[0] | ||
| .split(".", 1)[0] | ||
| .casefold() | ||
| ) | ||
| if module not in modules: | ||
| continue | ||
| name = normalized.rsplit("/", 1)[-1] | ||
| if name.casefold().startswith("test_") and name.casefold().endswith(".py"): | ||
| test_files.append(normalized) | ||
| covered.add(module) | ||
| if "/recordings/" in normalized: | ||
| recording_files.append(normalized) | ||
| covered.add(module) | ||
|
|
||
| uncovered = sorted(modules - covered) | ||
| return { | ||
| "applicable": bool(production_files), | ||
| "gap": bool(uncovered), | ||
| "modules": sorted(modules), | ||
| "uncovered_modules": uncovered, | ||
| "production_files": production_files, | ||
| "test_files": test_files, | ||
| "recording_files": recording_files, | ||
| } |
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,80 @@ | ||
| """Infer an Azure CLI module or extension from trusted repository structure.""" | ||
|
|
||
|
|
||
| def infer_target_for_repo(repo_full_name, text, pr_files): | ||
| """Resolve a sanitized issue or PR diff to a live CLI target.""" | ||
| if repo_full_name != "Azure/azure-cli": | ||
| raise ValueError("infer_target_for_repo is restricted to Azure/azure-cli") | ||
|
|
||
| modules = list_repository_directories( | ||
| source_repository="Azure/azure-cli", | ||
| ) | ||
| extensions = list_repository_directories( | ||
| source_repository="Azure/azure-cli-extensions", | ||
| ) | ||
|
|
||
| def normalize(value): | ||
| return "".join( | ||
| character | ||
| for character in str(value or "").casefold() | ||
| if character.isalnum() | ||
| ) | ||
|
|
||
| def resolve(candidate): | ||
| candidate_normalized = normalize(candidate) | ||
| for extension in extensions: | ||
| if normalize(extension) == candidate_normalized: | ||
| return { | ||
| "kind": "extension", | ||
| "name": extension, | ||
| "repo": "Azure/azure-cli-extensions", | ||
| } | ||
| for module in modules: | ||
| if normalize(module) == candidate_normalized: | ||
| return { | ||
| "kind": "module", | ||
| "name": module, | ||
| "repo": "Azure/azure-cli", | ||
| } | ||
| return None | ||
|
|
||
| scores = {} | ||
| for path in pr_files or []: | ||
| parts = str(path).replace("\\", "/").split("/") | ||
| if "command_modules" in parts: | ||
| index = parts.index("command_modules") | ||
| if index + 1 < len(parts): | ||
| candidate = parts[index + 1] | ||
| scores[candidate] = scores.get(candidate, 0) + 10 | ||
| elif len(parts) > 1 and parts[0].casefold() == "src": | ||
| candidate = parts[1] | ||
| scores[candidate] = scores.get(candidate, 0) + 10 | ||
| if pr_files: | ||
| for candidate in sorted(scores, key=lambda item: (-scores[item], item)): | ||
| target = resolve(candidate) | ||
| if target is not None: | ||
| return target | ||
| return {"kind": "none", "name": None, "repo": None} | ||
|
|
||
| cleaned = "".join( | ||
| character if character.isalnum() or character in "-_./" else " " | ||
| for character in str(text or "").casefold() | ||
| ) | ||
| words = cleaned.split() | ||
| for index, word in enumerate(words): | ||
| if word == "az" and index + 1 < len(words): | ||
| candidate = words[index + 1] | ||
| scores[candidate] = scores.get(candidate, 0) + 5 | ||
| if word.startswith("src/"): | ||
| parts = word.split("/") | ||
| if len(parts) > 1: | ||
| candidate = parts[1] | ||
| scores[candidate] = scores.get(candidate, 0) + 3 | ||
| if "command_modules/" in word: | ||
| candidate = word.split("command_modules/", 1)[1].split("/", 1)[0] | ||
| scores[candidate] = scores.get(candidate, 0) + 3 | ||
| for candidate in sorted(scores, key=lambda item: (-scores[item], item)): | ||
| target = resolve(candidate) | ||
| if target is not None: | ||
| return target | ||
| return {"kind": "unknown", "name": None, "repo": None} |
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,11 @@ | ||
| """Bind generation-source promotion to Azure CLI.""" | ||
|
|
||
|
|
||
| def promote_aaz_fork_pr(fork_pr_number, title, body): | ||
| """Promote one validated AAZ fork pull request.""" | ||
| return promote_generation_source_fork_pr( | ||
| repository=None, | ||
| fork_pr_number=fork_pr_number, | ||
| title=title, | ||
| body=body, | ||
| ) |
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,12 @@ | ||
| """Bind durable generation-source task creation to Azure CLI.""" | ||
|
|
||
|
|
||
| def start_aaz_source_task(issue_number, downstream_pr_url, changed_files, prompt_context): | ||
| """Start the configured AAZ source task for an Azure CLI pull request.""" | ||
| return start_generation_source_task( | ||
| repository=None, | ||
| issue_number=issue_number, | ||
| downstream_pr_url=downstream_pr_url, | ||
| changed_files=changed_files, | ||
| prompt_context=prompt_context, | ||
| ) |
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,22 @@ | ||
| """Own the Azure CLI to CLI Extensions implementation handoff.""" | ||
|
|
||
|
|
||
| def start_extension_tracker_task(issue_number, view, target, prompt, command, summary): | ||
| """Create or resume the scoped extension tracker and Copilot task.""" | ||
| if ( | ||
| not isinstance(target, dict) | ||
| or target.get("repo") != "Azure/azure-cli-extensions" | ||
| or not target.get("name") | ||
| ): | ||
| raise ValueError( | ||
| "start_extension_tracker_task requires a CLI Extensions target" | ||
| ) | ||
| return start_repository_handoff_task( | ||
| repository=None, | ||
| issue_number=issue_number, | ||
| view=view, | ||
| target=target, | ||
| prompt=prompt, | ||
| command=command, | ||
| summary=summary, | ||
| ) |
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
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.