From d76ba41e8fef5af754e796df59fa32646b51c2e0 Mon Sep 17 00:00:00 2001 From: Arthur Pinto Date: Fri, 15 May 2026 11:14:01 -0300 Subject: [PATCH 1/2] chore(build): rebuild plugin-copilot after create-pr ADO upgrade Regenerated plugin-copilot/ to reflect feat(skills) from #17: - workflow-create-pr/SKILL.md now includes Azure DevOps support Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com> --- .../skills/workflow-create-pr/SKILL.md | 186 +++++++++++++++--- 1 file changed, 163 insertions(+), 23 deletions(-) diff --git a/plugin-copilot/skills/workflow-create-pr/SKILL.md b/plugin-copilot/skills/workflow-create-pr/SKILL.md index 8e2a3df..fbccf1f 100644 --- a/plugin-copilot/skills/workflow-create-pr/SKILL.md +++ b/plugin-copilot/skills/workflow-create-pr/SKILL.md @@ -2,18 +2,18 @@ name: create-pr description: | Create a pull request with conventional commits and a structured description. - Use when the user wants to open a PR, commit changes, or submit work for - review. allowed-tools: shell + Supports GitHub and Azure DevOps — platform is auto-detected from the git remote. + Use when the user wants to open a PR, commit changes, or submit work for review. --- # Create PR Command -> Automate professional pull request creation with conventional commits and structured descriptions +> Automate professional pull request creation with conventional commits and structured descriptions — for both **GitHub** and **Azure DevOps** ## Usage ```bash -/create-pr # Auto-detect changes and create PR +/create-pr # Auto-detect platform and create PR /create-pr "feat: add user auth" # Create PR with custom title /create-pr --draft # Create as draft PR /create-pr --review # Run dual AI review before PR creation @@ -22,6 +22,49 @@ description: | --- +## Platform Detection + +At the start of every run, detect the remote platform: + +```bash +git remote get-url origin +``` + +| Remote URL Pattern | Platform | +|--------------------|----------| +| `*github.com*` | **GitHub** → use `gh` CLI | +| `*dev.azure.com*` or `*visualstudio.com*` | **Azure DevOps** → use `az repos` CLI | + +Extract Azure DevOps coordinates when applicable: + +```bash +# URL format A (modern): https://dev.azure.com/{org}/{project}/_git/{repo} +# URL format B (legacy): https://{org}.visualstudio.com/{project}/_git/{repo} +# +# Example (legacy): +# https://myorg.visualstudio.com/My%20Project/_git/my-repo +# → org: myorg +# → project: My Project (URL-decode %20 → space) +# → repo: my-repo + +REMOTE_URL=$(git remote get-url origin) + +# For legacy visualstudio.com URLs, extract: +# ADO_ORG = https://.visualstudio.com +# ADO_PROJECT = URL-decoded path segment before /_git/ +# ADO_REPO = path segment after /_git/ + +ADO_ORG="https://.visualstudio.com" # or https://dev.azure.com/ +ADO_PROJECT="" # URL-decode if percent-encoded (e.g. My%20Project → "My Project") +ADO_REPO="" +``` + +> **Note:** Project names may be URL-encoded (e.g. `My%20Project`). Always decode before passing to `az repos` commands — the CLI accepts the human-readable name. + +> If the platform cannot be determined, ask the user: **"Is this a GitHub or Azure DevOps repository?"** + +--- + ## Pre-PR Review Option When using `--review`, the command runs a **dual AI review** (CodeRabbit + Claude) before creating the PR: @@ -80,11 +123,12 @@ source ~/.zshrc && coderabbit review --plain 2>&1 This command streamlines PR creation by: -1. **Analyzing** all staged/unstaged changes -2. **Categorizing** changes by type (feat/fix/refactor/docs) -3. **Generating** conventional commit messages -4. **Building** structured PR descriptions with test plans -5. **Creating** the PR via GitHub CLI +1. **Detecting** the remote platform (GitHub or Azure DevOps) +2. **Analyzing** all staged/unstaged changes +3. **Categorizing** changes by type (feat/fix/refactor/docs) +4. **Generating** conventional commit messages +5. **Building** structured PR descriptions with test plans +6. **Creating** the PR via the appropriate CLI (`gh` for GitHub, `az repos` for Azure DevOps) --- @@ -171,9 +215,9 @@ Use AskUserQuestion to confirm: - Are there any breaking changes? - Options: Yes (describe), No -**Question 4: Related Issues** -- Link to any related issues? -- (Open text - e.g., "Closes #123") +**Question 4: Related Items** *(platform-aware)* +- **GitHub**: Link to any related issues? (e.g., "Closes #123") +- **Azure DevOps**: Link to any related work items? (e.g., work item IDs: `1234 5678`) ### Step 5: Build PR Description @@ -214,13 +258,13 @@ Generate structured description following this template: {Describe breaking changes or "None"} -## Related Issues +## Related Items -{Closes #XXX or "None"} +{GitHub: "Closes #XXX" | Azure DevOps: "Work Items: #1234 #5678" | "None"} --- -Generated with [Claude Code](https://claude.ai/code) +Generated with [GitHub Copilot](https://github.com/features/copilot) ``` ### Step 6: Create Branch (if needed) @@ -250,6 +294,8 @@ git push -u origin ### Step 8: Create PR +#### GitHub + ```bash gh pr create \ --title "(): " \ @@ -259,16 +305,68 @@ gh pr create \ For draft PRs: ```bash -gh pr create --draft ... +gh pr create --draft \ + --title "(): " \ + --body "" \ + --base main +``` + +#### Azure DevOps + +Requires the [Azure CLI](https://learn.microsoft.com/cli/azure/install-azure-cli) with the `azure-devops` extension: + +```bash +# One-time setup (if not already installed) +az extension add --name azure-devops +az devops configure --defaults organization=$ADO_ORG project=$ADO_PROJECT +``` + +```bash +az repos pr create \ + --title "(): " \ + --description "" \ + --source-branch "" \ + --target-branch main \ + --repository "$ADO_REPO" \ + --project "$ADO_PROJECT" \ + --organization "$ADO_ORG" +``` + +For draft PRs: +```bash +az repos pr create --draft \ + --title "(): " \ + --description "" \ + --source-branch "" \ + --target-branch main \ + --repository "$ADO_REPO" \ + --project "$ADO_PROJECT" \ + --organization "$ADO_ORG" +``` + +Linking work items: +```bash +az repos pr create \ + ... \ + --work-items 1234 5678 +``` + +After PR creation, set reviewers (optional): +```bash +az repos pr reviewer add \ + --id \ + --reviewers "user@org.com" "team@org.com" ``` --- ## Output -- **Branch:** `/` -- **Commit:** Conventional commit format -- **PR URL:** Returned from `gh pr create` +| Field | GitHub | Azure DevOps | +|-------|--------|--------------| +| **Branch** | `/` | `/` | +| **Commit** | Conventional commit format | Conventional commit format | +| **PR URL** | `https://github.com/org/repo/pull/` | `https://dev.azure.com/org/project/_git/repo/pullrequest/` | --- @@ -330,12 +428,12 @@ BRANCH ## Examples -### Example 1: Feature PR +### Example 1: Feature PR (GitHub) ```bash /create-pr -# Detected: New files in src/handlers/ +# Detected: New files in src/handlers/, remote: github.com # Suggested: feat(auth): add OAuth2 refresh support → Created branch: feat/oauth2-refresh @@ -343,7 +441,7 @@ BRANCH → PR: https://github.com/org/repo/pull/42 ``` -### Example 2: Refactor PR +### Example 2: Refactor PR (GitHub) ```bash /create-pr "refactor(agents): standardize agent definitions" @@ -353,7 +451,7 @@ BRANCH → PR: https://github.com/org/repo/pull/43 ``` -### Example 3: Documentation PR +### Example 3: Documentation PR — Draft (GitHub) ```bash /create-pr --draft @@ -366,6 +464,48 @@ BRANCH → Draft PR: https://github.com/org/repo/pull/44 ``` +### Example 4: Feature PR (Azure DevOps) + +```bash +/create-pr + +# Detected: New files in src/handlers/ +# Remote: https://myorg.visualstudio.com/My%20Project/_git/my-repo +# → Org: https://myorg.visualstudio.com +# → Project: My Project +# → Repo: my-repo +# Suggested: feat(auth): add OAuth2 refresh support + +→ Created branch: feat/oauth2-refresh +→ Committed: feat(auth): add OAuth2 token refresh +→ PR: https://myorg.visualstudio.com/My%20Project/_git/my-repo/pullrequest/101 +``` + +### Example 5: Bug Fix PR with Work Item (Azure DevOps) + +```bash +/create-pr "fix(parser): handle null date values" + +# Remote: https://myorg.visualstudio.com/My%20Project/_git/my-repo +# Linked work item: 4521 +→ Created branch: fix/parser-null-dates +→ Committed: fix(parser): handle null date values +→ PR: https://myorg.visualstudio.com/My%20Project/_git/my-repo/pullrequest/102 +→ Work Item #4521 linked +``` + +### Example 6: Draft PR (Azure DevOps) + +```bash +/create-pr --draft + +# Remote: https://myorg.visualstudio.com/My%20Project/_git/my-repo +# Suggested: feat(api): add pagination support + +→ Created branch: feat/api-pagination +→ Draft PR: https://myorg.visualstudio.com/My%20Project/_git/my-repo/pullrequest/103 +``` + --- ## Tips From ae8fc6335fdcca5c8391ec52bfe5136eaf1787eb Mon Sep 17 00:00:00 2001 From: Arthur Pinto Date: Fri, 15 May 2026 17:04:39 -0300 Subject: [PATCH 2/2] feat(skills): develop-first base branch detection in create-pr - Add Step 1 to detect if 'develop' exists on remote before PR creation - Store result as \ (develop or main) and use in all commands - Apply \ to git log, gh pr create, and az repos pr create - Renumber steps 1-9 to accommodate new detection step - Update quality checklist with base branch resolution check Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com> --- .github/sdd/.detected-stack.md | 2 +- .github/skills/workflow-create-pr/SKILL.md | 47 +++++++++++++------ .../skills/workflow-create-pr/SKILL.md | 47 +++++++++++++------ 3 files changed, 65 insertions(+), 31 deletions(-) diff --git a/.github/sdd/.detected-stack.md b/.github/sdd/.detected-stack.md index b303d8d..6d12e82 100644 --- a/.github/sdd/.detected-stack.md +++ b/.github/sdd/.detected-stack.md @@ -1,6 +1,6 @@ # Detected Stack -> Auto-generated by `scripts/init-workspace.sh` at 2026-05-13T14:55:59Z. +> Auto-generated by `scripts/init-workspace.sh` at 2026-05-15T13:03:02Z. > Re-run to refresh. Delete this file to force re-detection on next session. No recognized stack detected. AgentSpec will use generic agents. diff --git a/.github/skills/workflow-create-pr/SKILL.md b/.github/skills/workflow-create-pr/SKILL.md index 102a45e..12095b0 100644 --- a/.github/skills/workflow-create-pr/SKILL.md +++ b/.github/skills/workflow-create-pr/SKILL.md @@ -134,13 +134,29 @@ This command streamlines PR creation by: ## Process -### Step 1: Analyze Changes +### Step 1: Detect Base Branch + +Before analyzing changes, resolve the target base branch: + +```bash +# Check if 'develop' exists on the remote +git ls-remote --heads origin develop +``` + +| Result | Base branch | +|--------|-------------| +| Output is non-empty | `develop` | +| Output is empty | `main` | + +Store the result as `BASE_BRANCH` and use it in every subsequent step. + +### Step 2: Analyze Changes ```bash # Run these commands to understand the change scope git status git diff --stat -git log origin/main..HEAD --oneline +git log origin/$BASE_BRANCH..HEAD --oneline ``` Categorize files into change types: @@ -159,7 +175,7 @@ style: Formatting, whitespace perf: Performance improvements ``` -### Step 2: Determine PR Type +### Step 3: Determine PR Type Based on file analysis, identify the primary change type: @@ -175,7 +191,7 @@ Based on file analysis, identify the primary change type: | `.github/kb/**` | `docs(kb):` | | `.github/sdd/**` | `docs(sdd):` | -### Step 3: Generate Commit Message +### Step 4: Generate Commit Message Use Conventional Commits format: @@ -199,7 +215,7 @@ feat(auth): add OAuth2 token refresh flow Co-Authored-By: Claude ``` -### Step 4: Ask Clarifying Questions +### Step 5: Ask Clarifying Questions Use AskUserQuestion to confirm: @@ -219,7 +235,7 @@ Use AskUserQuestion to confirm: - **GitHub**: Link to any related issues? (e.g., "Closes #123") - **Azure DevOps**: Link to any related work items? (e.g., work item IDs: `1234 5678`) -### Step 5: Build PR Description +### Step 6: Build PR Description Generate structured description following this template: @@ -267,10 +283,10 @@ Generate structured description following this template: Generated with [GitHub Copilot](https://github.com/features/copilot) ``` -### Step 6: Create Branch (if needed) +### Step 7: Create Branch (if needed) ```bash -# If on main, create feature branch +# If on main or develop, create feature branch git checkout -b / # Examples: @@ -279,7 +295,7 @@ git checkout -b fix/parser-null-handling git checkout -b refactor/agents-standardization ``` -### Step 7: Commit and Push +### Step 8: Commit and Push ```bash # Stage all changes (or specific files) @@ -292,7 +308,7 @@ git commit -m "" git push -u origin ``` -### Step 8: Create PR +### Step 9: Create PR #### GitHub @@ -300,7 +316,7 @@ git push -u origin gh pr create \ --title "(): " \ --body "" \ - --base main + --base $BASE_BRANCH ``` For draft PRs: @@ -308,7 +324,7 @@ For draft PRs: gh pr create --draft \ --title "(): " \ --body "" \ - --base main + --base $BASE_BRANCH ``` #### Azure DevOps @@ -326,7 +342,7 @@ az repos pr create \ --title "(): " \ --description "" \ --source-branch "" \ - --target-branch main \ + --target-branch $BASE_BRANCH \ --repository "$ADO_REPO" \ --project "$ADO_PROJECT" \ --organization "$ADO_ORG" @@ -338,7 +354,7 @@ az repos pr create --draft \ --title "(): " \ --description "" \ --source-branch "" \ - --target-branch main \ + --target-branch $BASE_BRANCH \ --repository "$ADO_REPO" \ --project "$ADO_PROJECT" \ --organization "$ADO_ORG" @@ -389,7 +405,8 @@ PR DESCRIPTION BRANCH [ ] Branch name matches convention -[ ] Not committing directly to main +[ ] Not committing directly to main or develop +[ ] Base branch resolved (develop if it exists, otherwise main) [ ] All changes are staged ``` diff --git a/plugin-copilot/skills/workflow-create-pr/SKILL.md b/plugin-copilot/skills/workflow-create-pr/SKILL.md index fbccf1f..903a2d6 100644 --- a/plugin-copilot/skills/workflow-create-pr/SKILL.md +++ b/plugin-copilot/skills/workflow-create-pr/SKILL.md @@ -134,13 +134,29 @@ This command streamlines PR creation by: ## Process -### Step 1: Analyze Changes +### Step 1: Detect Base Branch + +Before analyzing changes, resolve the target base branch: + +```bash +# Check if 'develop' exists on the remote +git ls-remote --heads origin develop +``` + +| Result | Base branch | +|--------|-------------| +| Output is non-empty | `develop` | +| Output is empty | `main` | + +Store the result as `BASE_BRANCH` and use it in every subsequent step. + +### Step 2: Analyze Changes ```bash # Run these commands to understand the change scope git status git diff --stat -git log origin/main..HEAD --oneline +git log origin/$BASE_BRANCH..HEAD --oneline ``` Categorize files into change types: @@ -159,7 +175,7 @@ style: Formatting, whitespace perf: Performance improvements ``` -### Step 2: Determine PR Type +### Step 3: Determine PR Type Based on file analysis, identify the primary change type: @@ -175,7 +191,7 @@ Based on file analysis, identify the primary change type: | `${COPILOT_PLUGIN_ROOT}/kb/**` | `docs(kb):` | | `.github/sdd/**` | `docs(sdd):` | -### Step 3: Generate Commit Message +### Step 4: Generate Commit Message Use Conventional Commits format: @@ -199,7 +215,7 @@ feat(auth): add OAuth2 token refresh flow Co-Authored-By: Claude ``` -### Step 4: Ask Clarifying Questions +### Step 5: Ask Clarifying Questions Use AskUserQuestion to confirm: @@ -219,7 +235,7 @@ Use AskUserQuestion to confirm: - **GitHub**: Link to any related issues? (e.g., "Closes #123") - **Azure DevOps**: Link to any related work items? (e.g., work item IDs: `1234 5678`) -### Step 5: Build PR Description +### Step 6: Build PR Description Generate structured description following this template: @@ -267,10 +283,10 @@ Generate structured description following this template: Generated with [GitHub Copilot](https://github.com/features/copilot) ``` -### Step 6: Create Branch (if needed) +### Step 7: Create Branch (if needed) ```bash -# If on main, create feature branch +# If on main or develop, create feature branch git checkout -b / # Examples: @@ -279,7 +295,7 @@ git checkout -b fix/parser-null-handling git checkout -b refactor/agents-standardization ``` -### Step 7: Commit and Push +### Step 8: Commit and Push ```bash # Stage all changes (or specific files) @@ -292,7 +308,7 @@ git commit -m "" git push -u origin ``` -### Step 8: Create PR +### Step 9: Create PR #### GitHub @@ -300,7 +316,7 @@ git push -u origin gh pr create \ --title "(): " \ --body "" \ - --base main + --base $BASE_BRANCH ``` For draft PRs: @@ -308,7 +324,7 @@ For draft PRs: gh pr create --draft \ --title "(): " \ --body "" \ - --base main + --base $BASE_BRANCH ``` #### Azure DevOps @@ -326,7 +342,7 @@ az repos pr create \ --title "(): " \ --description "" \ --source-branch "" \ - --target-branch main \ + --target-branch $BASE_BRANCH \ --repository "$ADO_REPO" \ --project "$ADO_PROJECT" \ --organization "$ADO_ORG" @@ -338,7 +354,7 @@ az repos pr create --draft \ --title "(): " \ --description "" \ --source-branch "" \ - --target-branch main \ + --target-branch $BASE_BRANCH \ --repository "$ADO_REPO" \ --project "$ADO_PROJECT" \ --organization "$ADO_ORG" @@ -389,7 +405,8 @@ PR DESCRIPTION BRANCH [ ] Branch name matches convention -[ ] Not committing directly to main +[ ] Not committing directly to main or develop +[ ] Base branch resolved (develop if it exists, otherwise main) [ ] All changes are staged ```