diff --git a/.github/agents/custom-code.agent.md b/.github/agents/custom-code.agent.md new file mode 100644 index 00000000000..4674af599db --- /dev/null +++ b/.github/agents/custom-code.agent.md @@ -0,0 +1,30 @@ +--- +name: custom-code-agent +description: "Use when adding or modifying Azure CLI command module custom code, including AAZ subclass custom, legacy SDK-backed custom, and legacy non-SDK custom." +--- + +You are a focused coding sub-agent for Azure CLI command module custom code. + +Goals: +- Add or modify command logic in custom.py. +- Register commands in commands.py. +- Update argument definitions in _params.py. +- Keep command help in _help.py consistent. + +Rules: +- Prefer small, targeted edits. +- Before editing custom code, use `common-custom-code-router` unless the route is already recorded in an OpenSpec design or is otherwise unambiguous from local evidence. +- If an OpenSpec design records the route and implementation plan, follow it. Do not choose a different route during implementation unless the design is updated. +- Use the selected route to apply exactly one generation workflow: `common-aaz-custom-code-generation`, `common-legacy-sdk-backed-custom-code-generation`, or `common-legacy-non-sdk-custom-code-generation`. +- Preserve existing command behavior unless the request asks for a change. +- For any behavior change, perform a consistency pass over the affected command surface and update related implementation, argument definitions, user-facing help, validation/errors, examples, and focused tests as needed. +- When updating tests, do not treat existing recordings as the source of truth for expected response values or response shape. Use recordings only as historical evidence to locate affected scenarios, understand previous responses, and identify existing assertions. Expected values and response structure must come from the current product/API specification and the requested custom code change; treat documentation as supporting context only, especially when the API behavior is changing. If existing recordings disagree with the new specification, update tests to the specification and expect recordings to be re-recorded rather than relaxing assertions to old values or old structures. +- Treat `_params.py` argument help as user-facing command help, the same as authored help in `_help.py`. +- Do not edit generated AAZ files under `aaz/latest` unless the user explicitly asks to modify generated output and accepts regeneration risk. +- Ignore local/personal memory by default and do not rely on it for behavior decisions. +- Use only user request, current session context, and repository-tracked guidance as authoritative inputs. +- Do not create, edit, or delete files outside this repository unless the user explicitly asks and confirms. +- When creating skills in this workflow, only add module-specific skills. +- Module skill names must follow `module-`. +- Treat agent instructions as az-cli level guidance, not module-local policy. +- If a requested specification looks general and reusable across modules, ask to align with the owner alias `bernardpan` before finalizing it as agent-level policy. diff --git a/.github/instructions/agent-safety.instructions.md b/.github/instructions/agent-safety.instructions.md new file mode 100644 index 00000000000..36ba635ed63 --- /dev/null +++ b/.github/instructions/agent-safety.instructions.md @@ -0,0 +1,13 @@ +--- +applyTo: "**" +description: "Global safety and scope rules for all agents in this repository." +--- + +When handling tasks in this repository: + +- Treat repository files and in-session user instructions as the primary source of truth. +- Ignore local/personal memory by default unless the user explicitly asks to use memory content. +- Do not create, edit, or delete files outside this repository unless the user explicitly asks and confirms. +- Do not modify machine-level/user-level settings (for example shell profile, global git config, VS Code user settings) unless explicitly requested. +- Avoid destructive operations by default; ask for confirmation before deleting resources or running irreversible commands. +- Keep edits minimal and scoped to the user request. diff --git a/.github/instructions/custom-code.instructions.md b/.github/instructions/custom-code.instructions.md new file mode 100644 index 00000000000..406c1480ca5 --- /dev/null +++ b/.github/instructions/custom-code.instructions.md @@ -0,0 +1,23 @@ +--- +applyTo: "src/azure-cli/azure/cli/command_modules/**/{custom.py,commands.py,_params.py,_help.py}" +description: "Guidance for editing Azure CLI command module custom code files." +--- + +When editing Azure CLI command modules: + +- Keep command registration, parameters, and handlers in sync. +- If a new command is added, wire it in commands.py and define args in _params.py. +- Keep return shapes compatible with existing CLI output patterns. +- Keep help/examples aligned with command behavior. +- Prefer concise error messages through CLIError when user input is invalid. +- Keep these instructions at az-cli level; do not add module-specific policy here. +- If a new rule appears to be a general specification, sync with owner in the Azure CLI team before promoting it to shared instruction guidance. + +Before generating or modifying custom code, read and apply these repository docs: + +- doc/authoring_command_modules/authoring_commands.md (command registration patterns, custom command wiring, argument and validator conventions) +- doc/command_guidelines.md (CLI UX and argument design expectations) +- doc/error_handling_guidelines.md (preferred Azure CLI error types and patterns) +- doc/authoring_help.md (help authoring format in _help.py/help.yaml) +- doc/reference_doc_guidelines.md (example quality and formatting requirements) +- doc/authoring_tests.md (test coverage and scenario test expectations) diff --git a/.github/prompts/opsx-apply.prompt.md b/.github/prompts/opsx-apply.prompt.md new file mode 100644 index 00000000000..c83b479f783 --- /dev/null +++ b/.github/prompts/opsx-apply.prompt.md @@ -0,0 +1,153 @@ +--- +description: Implement tasks from an OpenSpec change (Experimental) +--- + +Implement tasks from an OpenSpec change. + +**Store selection:** If the user names a store (a store is a standalone OpenSpec repo registered on this machine) or the work lives in one, run `openspec store list --json` to discover registered store ids, then pass `--store ` on the commands that read or write specs and changes (`new change`, `status`, `instructions`, `list`, `show`, `validate`, `archive`, `doctor`, `context`). Other commands do not take the flag. Hints printed by commands already carry the flag; keep it on follow-ups. Without a store, commands act on the nearest local `openspec/` root. + +**Input**: Optionally specify a change name (e.g., `/opsx:apply add-auth`). If omitted, check if it can be inferred from conversation context. If vague or ambiguous you MUST prompt for available changes. + +**Steps** + +1. **Select the change** + + If a name is provided, use it. Otherwise: + - Infer from conversation context if the user mentioned a change + - Auto-select if only one active change exists + - If ambiguous, run `openspec list --json` to get available changes and use the **AskUserQuestion tool** to let the user select + + Always announce: "Using change: " and how to override (e.g., `/opsx:apply `). + +2. **Check status to understand the schema** + ```bash + openspec status --change "" --json + ``` + Parse the JSON to understand: + - `schemaName`: The workflow being used (e.g., "spec-driven") + - `planningHome`, `changeRoot`, and `actionContext`: planning scope and edit constraints + - Which artifact contains the tasks (typically "tasks" for spec-driven, check status for others) + +3. **Get apply instructions** + + ```bash + openspec instructions apply --change "" --json + ``` + + This returns: + - `contextFiles`: artifact ID -> array of concrete file paths (varies by schema) + - Progress (total, complete, remaining) + - Task list with status + - Dynamic instruction based on current state + + **Handle states:** + - If `state: "blocked"` (missing artifacts): show message, suggest using `/opsx:continue` + - If `state: "all_done"`: congratulate, suggest archive + - Otherwise: proceed to implementation + +4. **Read context files** + + Read every file path listed under `contextFiles` from the apply instructions output. + The files depend on the schema being used: + - **spec-driven**: proposal, specs, design, tasks + - Other schemas: follow the contextFiles from CLI output + +5. **Show current progress** + + Display: + - Schema being used + - Progress: "N/M tasks complete" + - Remaining tasks overview + - Dynamic instruction from CLI + +6. **Implement tasks (loop until done or blocked)** + + For each pending task: + - Show which task is being worked on + - Make the code changes required + - Keep changes minimal and focused + - Mark task complete in the tasks file: `- [ ]` → `- [x]` + - Continue to next task + + **Pause if:** + - Task is unclear → ask for clarification + - Implementation reveals a design issue → suggest updating artifacts + - Error or blocker encountered → report and wait for guidance + - User interrupts + +7. **On completion or pause, show status** + + Display: + - Tasks completed this session + - Overall progress: "N/M tasks complete" + - If all done: suggest archive + - If paused: explain why and wait for guidance + +**Output During Implementation** + +``` +## Implementing: (schema: ) + +Working on task 3/7: +[...implementation happening...] +✓ Task complete + +Working on task 4/7: +[...implementation happening...] +✓ Task complete +``` + +**Output On Completion** + +``` +## Implementation Complete + +**Change:** +**Schema:** +**Progress:** 7/7 tasks complete ✓ + +### Completed This Session +- [x] Task 1 +- [x] Task 2 +... + +All tasks complete! You can archive this change with `/opsx:archive`. +``` + +**Output On Pause (Issue Encountered)** + +``` +## Implementation Paused + +**Change:** +**Schema:** +**Progress:** 4/7 tasks complete + +### Issue Encountered + + +**Options:** +1.