microsoft/hve-core

Public

mirrored fromhttps://github.com/microsoft/hve-coreAvailable

CodeCommitsIssuesPull requestsActionsInsightsSecurity
hve-core-v3.2.2

Branches

Tags

  • No tags available.
0Branches0Tags
Go to file
Add file
Code

Clone

HTTPS

Download ZIP

.github/instructions/ado/ado-create-pull-request.instructions.md

790lines · modecode

1---
2description: "Required protocol for creating Azure DevOps pull requests with work item discovery, reviewer identification, and automated linking."
3applyTo: '**/.copilot-tracking/pr/new/**'
4---
5
6# Azure DevOps Pull Request Creation
7
8Follow all instructions from #file:./ado-wit-planning.instructions.md for planning file conventions while executing this workflow.
9
10## Scope
11
12Apply this procedure when creating a new Azure DevOps pull request with automated PR description generation, work item discovery and linking, reviewer identification from git history, and complete traceability through planning documents.
13
14Output planning files to `.copilot-tracking/pr/new/<normalized-branch-name>/` using the specified Azure DevOps project `${input:adoProject}` and repository `${input:repository}`.
15
16## Inputs
17
18* `${input:adoProject}`: (Required) Azure DevOps project name or ID.
19* `${input:repository}`: (Required) Repository name or ID.
20* `${input:sourceBranch}`: (Optional) Source branch name. Defaults to current git branch.
21* `${input:baseBranch:origin/main}`: (Optional) Base branch for comparison.
22* `${input:similarityThreshold:50}`: (Optional) Minimum similarity score (0-100) for work item matching.
23* `${input:workItemStates:["New", "Active", "Resolved"]}`: (Optional) Work item state filter.
24* `${input:workItemIds}`: (Optional) Explicit work item IDs to link, bypassing discovery.
25* `${input:isDraft:false}`: (Optional) Create PR as draft.
26* `${input:noGates:false}`: (Optional) Skip user confirmation gates.
27* `${input:includeMarkdown:true}`: (Optional) Include markdown file diffs in PR reference.
28
29## Deliverables
30
31* `pr-reference.xml` - Git diff and commit history
32* `pr.md` - Pull request description
33* `pr-analysis.md` - Change analysis and work item findings
34* `reviewer-analysis.md` - Reviewer analysis with rationale
35* `planning-log.md` - Operational log
36* `handoff.md` - Final PR creation plan
37* Conversational recap with PR URL
38
39## Tooling
40
41Generate a PR reference XML containing commit history and diffs using the `pr-reference` skill, comparing against `${input:baseBranch}` and saving to the tracking directory. After generation, use the pr-reference skill to query the XML: extract changed file paths with change type filters and output format options, and read diff content in chunks by number, line range, or specific file path.
42When the skill is unavailable, parse the XML directly or use `git diff --name-status` and `git diff` commands for equivalent extraction.
43
44Git operations via `run_in_terminal`:
45
46* `git fetch <remote> <branch-name> --prune` to sync remote
47* `git config user.email` for current user
48* `git log --all --pretty=format:'%H %an <%ae>' -- <file-pattern> | head -20` for contributors
49
50### Azure DevOps MCP Tools
51
52* `mcp_ado_repo_get_repo_by_name_or_id` - Resolve repository IDs from name. Parameters: `project`, `repositoryNameOrId`.
53* `mcp_ado_repo_create_pull_request` - Create pull request. Required: `repositoryId`, `sourceRefName`, `targetRefName`, `title`. Optional: `description`, `isDraft`, `labels` (array), `workItems` (space-separated IDs), `forkSourceRepositoryId`.
54* `mcp_ado_repo_update_pull_request` - Update PR settings. Required: `repositoryId`, `pullRequestId`. Optional: `title`, `description`, `status` (Active|Abandoned), `isDraft`, `autoComplete`, `mergeStrategy` (NoFastForward|Squash|Rebase|RebaseMerge), `deleteSourceBranch`, `transitionWorkItems`, `bypassReason`, `labels`.
55* `mcp_ado_repo_update_pull_request_reviewers` - Add or remove reviewers. Required: `repositoryId`, `pullRequestId`, `reviewerIds` (array of GUIDs), `action` (add|remove).
56* `mcp_ado_wit_link_work_item_to_pull_request` - Link work item to PR. Required: `projectId` (GUID), `repositoryId`, `pullRequestId`, `workItemId`. Optional: `pullRequestProjectId` (for cross-project linking).
57* `mcp_ado_search_workitem` - Search work items. Parameters: `searchText`, `project`, `workItemType`, `state`, `assignedTo`, `top`, `skip`.
58* `mcp_ado_wit_get_work_item` - Get work item details. Parameters: `id`, `project`, `expand`, `fields`.
59* `mcp_ado_wit_get_work_items_batch_by_ids` - Batch get work items. Parameters: `project`, `ids` (array), `fields`.
60* `mcp_ado_core_get_identity_ids` - Resolve identity GUIDs from email or name. Parameters: `searchFilter`.
61
62Workspace utilities: `list_dir`, `read_file`, `grep_search`
63
64Persist all tool output into planning files per ado-wit-planning.instructions.md.
65
66## Tracking Directory Structure
67
68All PR creation tracking artifacts reside in `.copilot-tracking/pr/new/{{normalized branch name}}`.
69
70```plaintext
71.copilot-tracking/
72 pr/
73 new/
74 {{normalized branch name}}/
75 pr-reference.xml # Generated git diff and commit history
76 pr.md # Generated PR description
77 pr-analysis.md # Change analysis and work item findings
78 reviewer-analysis.md # Potential reviewer analysis
79 planning-log.md # Operational log
80 handoff.md # Final PR creation plan
81```
82
83**Branch Name Normalization Rules**:
84
85* Convert to lowercase characters
86* Replace `/` with `-`
87* Strip special characters except hyphens
88* Example: `feat/ACR-Private-Public` → `feat-acr-private-public`
89
90## Planning File Formats
91
92### pr-analysis.md
93
94````markdown
95# Pull Request Analysis - [Branch Name]
96* **Source Branch**: [Source branch name]
97* **Target Branch**: [Target branch name]
98* **Project**: [Azure DevOps project]
99* **Repository**: [Repository name or ID]
100
101## Change Summary
102
103[1-5 sentence summary of what changed based on pr-reference.xml analysis]
104
105## Changed Files
106
107* [file/path/one.ext]: [Brief description of changes]
108* [file/path/two.ext]: [Brief description of changes]
109
110## Commit Summary
111* [Aggregated summary of commit messages]
112
113## Work Item Discovery
114
115### Keyword Groups for Search
116
1171. [Keyword group 1]: [term1 OR term2 OR "multi word term"]
1182. [Keyword group 2]: [term1 OR term2]
119
120### Discovered Work Items
121
122#### ADO-[Work Item ID] - [Similarity Score] - [Type]
123* **Title**: [Work item title]
124* **State**: [Current state]
125* **Relevance Reasoning**: [Why this work item relates to the PR]
126* **User Decision**: [Pending|Link|Skip]
127
128## Notes
129
130* [Optional notes about the analysis]
131````
132
133### reviewer-analysis.md
134
135````markdown
136# Reviewer Analysis - [Branch Name]
137* **Current User**: [Current git user email]
138* **Changed Files**: [Count]
139
140## Contributor Analysis
141
142### Changed File: [file/path/one.ext]
143* **Recent Contributors** (last 20 commits):
144 * [Contributor 1 Name] <[email]> - [commit count] commits
145 * [Contributor 2 Name] <[email]> - [commit count] commits
146
147### Changed File: [file/path/two.ext]
148* **Recent Contributors** (last 20 commits):
149 * [Contributor 1 Name] <[email]> - [commit count] commits
150
151### Surrounding Files: [directory/**]
152* **Recent Contributors** (last 20 commits):
153 * [Contributor Name] <[email]> - [commit count] commits
154
155## Potential Reviewers (excluding current user)
156
1571. **[Reviewer 1 Name]** <[email]>
158 * **Identity ID**: [Azure DevOps GUID or "Manual addition required"]
159 * **Contribution Score**: [High|Medium|Low]
160 * **Files**: [List of changed files they contributed to]
161 * **Rationale**: [Why they would be a good reviewer]
162 * **User Decision**: [Pending|Required|Optional|Skip]
163
1642. **[Reviewer 2 Name]** <[email]>
165 * **Identity ID**: [Azure DevOps GUID or "Manual addition required"]
166 * **Contribution Score**: [High|Medium|Low]
167 * **Files**: [List of changed files they contributed to]
168 * **Rationale**: [Why they would be a good reviewer]
169 * **User Decision**: [Pending|Required|Optional|Skip]
170
171## Reviewer Recommendation
172
173* **Recommended Reviewers**: [List of high-contribution reviewers]
174* **Additional Reviewers**: [List of lower-contribution reviewers]
175````
176
177### handoff.md
178
179````markdown
180# Pull Request Creation Handoff
181* **Project**: [Azure DevOps project]
182* **Repository**: [Repository name or ID]
183* **Repository ID**: [Repository ID for MCP tool]
184* **Source Branch**: [Source branch name]
185* **Target Branch**: [Target branch name]
186* **Is Draft**: [true|false]
187
188## Planning Files
189
190* .copilot-tracking/pr/new/[normalized-branch-name]/handoff.md
191* .copilot-tracking/pr/new/[normalized-branch-name]/pr-analysis.md
192* .copilot-tracking/pr/new/[normalized-branch-name]/reviewer-analysis.md
193* .copilot-tracking/pr/new/[normalized-branch-name]/planning-log.md
194* .copilot-tracking/pr/new/[normalized-branch-name]/pr.md
195
196## PR Details
197
198### Title
199
200[Generated PR title from pr.md]
201
202### Description
203
204```markdown
205[Complete PR description from pr.md]
206```
207
208## Work Items to Link
209
210* [ ] ADO-[Work Item ID] - [Type] - [Title]
211 * **Similarity**: [Score]
212 * **Reason**: [Why linking this work item]
213* [ ] ADO-[Work Item ID] - [Type] - [Title]
214 * **Similarity**: [Score]
215 * **Reason**: [Why linking this work item]
216
217**Total Work Items**: [Count]
218
219## Reviewers to Add
220
221### Reviewers
222
223* [ ] [Reviewer Name] <[email]>
224 * **Rationale**: [Why they should review]
225
226* [ ] [Reviewer Name] <[email]>
227 * **Rationale**: [Why they should review]
228
229**Total Reviewers**: [Count]
230
231## MCP Tool Call Plan
232
233### 1. Create Pull Request
234
235**Tool**: `mcp_ado_repo_create_pull_request`
236
237**Parameters**:
238* `repositoryId`: "[Repository ID]"
239* `sourceRefName`: "refs/heads/[source-branch-name]"
240* `targetRefName`: "refs/heads/[target-branch-name]"
241* `title`: "[PR title from pr.md first line WITHOUT the markdown heading marker hash]"
242 * Example: `feat(scope): description` (NOT `# feat(scope): description`)
243* `description`: "[PR description from pr.md body WITH full markdown formatting]"
244* `isDraft`: [true|false]
245* `labels`: ["label-name"] (optional)
246* `workItems`: "[space-separated work item IDs]" (optional, alternative to separate linking calls)
247
248**Expected Result**: Pull request created with ID [PR-ID]
249
250### 2. Link Work Items
251
252**Tool**: `mcp_ado_wit_link_work_item_to_pull_request` (call once per work item)
253
254**Parameters for each work item**:
255* `projectId`: "[Project ID]"
256* `repositoryId`: "[Repository ID]"
257* `pullRequestId`: [PR-ID from step 1]
258* `workItemId`: [Work Item ID]
259
260**Total Calls**: [Count of work items to link]
261
262### 3. Add Reviewers
263
264**Tool**: `mcp_ado_repo_update_pull_request_reviewers`
265
266**Parameters**:
267* `repositoryId`: "[Repository ID]"
268* `pullRequestId`: [PR-ID from step 1]
269* `reviewerIds`: [[Array of resolved identity GUIDs from mcp_ado_core_get_identity_ids]]
270* `action`: "add"
271
272**Expected Result**: Reviewers added to pull request [PR-ID]
273
274**Note**: Reviewers without resolved identity IDs must be added manually via Azure DevOps UI.
275
276## User Signoff
277
278* [ ] PR details reviewed and approved
279* [ ] Work items confirmed
280* [ ] Reviewers confirmed
281* [ ] Ready to create PR
282
283**User Confirmation**: [Pending|Approved]
284````
285
286### planning-log.md
287
288````markdown
289# Planning Log - [Branch Name]
290
291* **Source Branch**: [branch name]
292* **Target Branch**: [target branch]
293* **Project**: [Azure DevOps project]
294* **Repository**: [Repository name]
295* **Current Phase**: [Phase number]
296* **Previous Phase**: [Phase number or N/A]
297
298## Phase Progress
299
300| Phase | Status | Notes |
301|----------------------------------|----------------------------------------|---------|
302| Phase 1: Setup | [Complete/In Progress/Pending] | [Notes] |
303| Phase 2: PR Description | [Complete/In Progress/Pending] | [Notes] |
304| Phase 3: Work Item Discovery | [Complete/In Progress/Pending/Skipped] | [Notes] |
305| Phase 3a: Work Item Creation | [Complete/In Progress/Pending/Skipped] | [Notes] |
306| Phase 4: Reviewer Identification | [Complete/In Progress/Pending] | [Notes] |
307| Phase 5: User Confirmation | [Complete/In Progress/Pending/Skipped] | [Notes] |
308| Phase 6: PR Creation | [Complete/In Progress/Pending] | [Notes] |
309| Phase 7: Final Recap | [Complete/In Progress/Pending] | [Notes] |
310
311## Artifacts
312
313* **pr-reference.xml**: [Generated/Existing/Pending]
314* **pr.md**: [Generated/Pending]
315* **pr-analysis.md**: [Generated/Pending]
316* **reviewer-analysis.md**: [Generated/Pending]
317* **handoff.md**: [Generated/Pending]
318
319## Work Items
320
321* Discovered: [Count]
322* Created: [Count or N/A]
323* Selected for linking: [Count]
324* IDs: [Comma-separated list]
325
326## Reviewers
327
328* Identified: [Count]
329* Identity resolved: [Count]
330* Pending manual addition: [Count]
331
332## Recovery Information
333
334If context is summarized, read all files from the planning directory and resume from the current phase recorded above.
335````
336
337## Protocol Overview
338
339This workflow follows a progressive confirmation model where user reviews and approves each section before proceeding:
340
3411. **Setup & Analysis** (Phases 1-4): Silent preparation - generate artifacts, analyze changes, discover work items and reviewers
3422. **User Review & Confirmation** (Phase 5): Present information in stages with confirmation gates
3433. **PR Creation** (Phase 6): Execute after final user signoff
3444. **Completion** (Phase 7): Deliver recap with PR URL
345
346Present each confirmation gate separately and wait for user response before proceeding to the next gate. Avoid presenting all information at once.
347
348### No-Gates Mode
349
350When `${input:noGates}` is true:
351
352* Skip Phase 5 (all confirmation gates) entirely
353* After completing Phase 4, proceed directly to Phase 6
354* Use all discovered work items (no user selection)
355* If Phase 3a created a work item, use that created work item automatically
356* Add minimum of 2 optional reviewers (top 2 by contribution score)
357* Create PR immediately with all discovered linkages
358* Deliver final recap in Phase 7 as usual
359
360## Required Phases
361
362### Phase 1: Setup and PR Reference Generation
363
364Execute without presenting details to user:
365
3661. Determine normalized branch name from `${input:sourceBranch}` or current git branch.
3672. Create planning directory: `.copilot-tracking/pr/new/<normalized-branch-name>/`
3683. Initialize `planning-log.md` with Phase-1 status.
3694. Check if `pr-reference.xml` exists:
370 * If exists: Use existing file silently.
371 * If not exists: Generate using the `pr-reference` skill with optional `--no-md-diff` flag if `${input:includeMarkdown}` is false.
3725. Read complete `pr-reference.xml`. For files exceeding 2000 lines, read in 1000-2000 line chunks, capturing complete commit boundaries before advancing to the next chunk.
3736. Log artifact in `planning-log.md` with status `Complete`.
374
375### Phase 2: Generate PR Description
376
377Execute without presenting to user yet:
378
3791. Analyze `pr-reference.xml` completely before writing any content. Include only changes visible in the reference file; do not invent or assume changes.
3802. Generate `pr.md` in the planning directory (not in root) following the PR File Format below.
3813. Extract commit types, scopes, and key changes for PR title and description.
3824. Use past tense for all descriptions.
3835. Describe WHAT changed, not speculating WHY.
3846. Use natural, conversational language that reads like human communication.
3857. Match tone and terminology from commit messages.
3868. Group and order changes by SIGNIFICANCE and IMPORTANCE (most significant first).
3879. Combine related changes into single descriptive points.
38810. Only add sub-bullets when they provide genuine clarification value.
38911. Only include "Notes," "Important," or "Follow-up" sections if supported by commit messages or code comments.
39012. Extract changed file list with descriptions for Gate 1 presentation.
39113. Log generation in `planning-log.md`.
392
393**PR File Format for pr.md**:
394
395```markdown
396# {{type}}({{scope}}): {{concise description}}
397
398{{Summary paragraph of overall changes in natural, human-friendly language}}
399
400- **{{type}}**(_{{scope}}_): {{description of change with key context included}}
401
402- **{{type}}**(_{{scope}}_): {{description of change}}
403 - {{sub-bullet only if it adds genuine clarification value}}
404
405- **{{type}}**: {{description of change without scope, including essential details}}
406
407## Notes (optional)
408
409- Note 1 identified from code comments or commit message
410- Note 2 identified from code comments or commit message
411
412## Important (optional)
413
414- Critical information 1 identified from code comments or commit message
415- Warning 2 identified from code comments or commit message
416
417## Follow-up Tasks (optional)
418
419- Task 1 with file reference
420- Task 2 with specific component mention
421
422{{emoji representing the changes}} - Generated by Copilot
423```
424
425**Type and Scope**:
426
427* Determine from commits in `pr-reference.xml`
428* Use branch name as primary source for type/scope
429* Common types: feat, fix, docs, chore, refactor, test, ci
430* Scope should reference component or area affected
431
432**Title Construction Rules**:
433
434* Format: `{type}({scope}): {concise description}`
435* If branch name is not descriptive, rely on commit messages
436* Keep concise but descriptive
437
438**Never Include**:
439
440* Changes related to linting errors or auto-generated documentation
441* Speculative benefits ("improves security") unless explicit in commits
442* Follow-up tasks for documentation or tests (unless in commit messages)
443
444### Phase 3: Discover Related Work Items
445
446**Skip this phase entirely if `${input:workItemIds}` is provided by the user.**
447
448Execute without presenting to user yet:
449
4501. Build ACTIVE KEYWORD GROUPS from:
451 * Changed file paths (component names, directories)
452 * Commit messages (subjects and bodies)
453 * Conventional commit scopes
454 * Technical terms from diff content
4552. For each keyword group, call `mcp_ado_search_workitem` with:
456 * `project`: `${input:adoProject}`
457 * `searchText`: constructed from keyword groups using OR/AND syntax
458 * `workItemType`: ["User Story", "Bug"] (NEVER include Feature or Epic)
459 * `state`: Parse `${input:workItemStates}` into array format
460 * `top`: 50; increment `skip` as needed
461 * Optional filters: `${input:areaPath}`, `${input:iterationPath}`
4623. Hydrate results via `mcp_ado_wit_get_work_item` (batch variant preferred).
4634. Compute similarity using semantic analysis of:
464 * Work item title + description vs. PR title + description
465 * Work item acceptance criteria vs. PR change summary
466 * Boost for matching commit scopes, file paths, technical terms
4675. Filter work items with similarity >= `${input:similarityThreshold}`.
4686. Capture findings in `pr-analysis.md` with relevance reasoning.
4697. Log discovered work items in `planning-log.md`.
4708. If NO viable work items are discovered (zero work items with similarity >= threshold):
471 * Proceed to Phase 3a - Create Work Item for PR
472 * After Phase 3a completion, continue to Phase 4
473
474### Phase 3a: Create Work Item for PR
475
476Execute this phase when Phase 3 discovers zero viable work items.
477
478Follow ado-wit-discovery.instructions.md and ado-update-wit-items.instructions.md to create a work item:
479
4801. Create planning directory `.copilot-tracking/workitems/discovery/<folder-name>/` using the branch name without prefix.
4812. Reuse `pr-reference.xml`, PR title, description, and keyword groups from previous phases.
4823. Follow ado-wit-discovery.instructions.md phases to plan creation of ONE User Story or Bug based on PR content. Derive type from branch name or commit type (feat → User Story, fix → Bug).
4834. Execute work item creation following ado-update-wit-items.instructions.md. Capture created work item ID in `handoff-logs.md`.
4845. Store created work item ID for Phase 6 linking. Update `pr-analysis.md` with created work item details.
485
486### Phase 4: Identify Potential Reviewers
487
488Execute without presenting to user yet:
489
4901. Get current user email: `git config user.email`
4912. For each changed file in `pr-reference.xml`:
492 * Extract file path
493 * Get recent contributors: `git log --all --pretty=format:'%H %an <%ae>' -- <file-path> | head -20`
494 * Parse output to count commits per author
4953. For surrounding directories of changed files:
496 * Use parent directory patterns (e.g., `path/to/dir/**`)
497 * Get recent contributors: `git log --all --pretty=format:'%H %an <%ae>' -- <dir-pattern> | head -20`
4984. Aggregate contributors across all changed files and directories:
499 * Count total commits per contributor
500 * Exclude current user
501 * Rank by contribution score (High: >10 commits, Medium: 3-10, Low: 1-2)
5025. Resolve Azure DevOps identity IDs:
503 * For each unique reviewer email, call `mcp_ado_core_get_identity_ids` with `searchFilter` set to the email
504 * Extract `id` (GUID) from response and store with reviewer record
505 * For GitHub noreply emails (`*@users.noreply.github.com`): Search git history for alternative email addresses using `git log --author="<username>" --pretty=format:'%ae' | sort -u`, then retry identity resolution with discovered alternatives
506 * If no match found after alternatives, mark reviewer for manual addition
507 * If multiple matches found, use most recent activity or mark for user disambiguation
5086. Capture analysis in `reviewer-analysis.md` with rationale and resolved identity IDs.
5097. Log potential reviewers and resolution status in `planning-log.md`.
510
511### Phase 5: User Review and Confirmation
512
513Skip this phase when `${input:noGates}` is true; proceed directly to Phase 6 using all discovered work items, created work items from Phase 3a, and top 2 reviewers by contribution score.
514
515Present each gate separately and wait for user approval before proceeding to the next gate.
516
517#### Gate 1: Changed Files Review
518
5191. Extract all changed files from `pr-reference.xml`.
5202. For each file, provide brief description of changes from diff analysis.
5213. Perform quality review and identify:
522 * Accidental or unintended changes (e.g., debug code, commented code)
523 * Missing files that should be tracked
524 * Extra files that should not be included (e.g., build artifacts, temp files)
525 * Security issues (secrets, credentials, PII)
526 * Compliance issues (non-compliant language, FIXME, WIP, etc in committed code)
527 * Code quality concerns (styling violations, linting issues)
528
529**File Count Handling**:
530
531* If ≤ 50 files: Present full list inline with change descriptions
532* If > 50 files: Provide summary statistics and link to `pr-analysis.md`, instruct user to review and confirm when ready
533
534**Presentation Format**:
535
536```markdown
537## 📄 Changed Files Review
538
539I've analyzed [count] changed files in your PR:
540
541### Modified Files
5421. [path/to/file1.ext]: [Brief description of changes]
5432. [path/to/file2.ext]: [Brief description of changes]
544
545### Quality Review
546✅ No Issues Found (or ⚠️ list issues requiring attention)
547
548Please review the changes. Reply with "Continue", "Remove [filename]", or "Add [filename]".
549```
550
551For changesets over 50 files, provide summary statistics and link to `pr-analysis.md`.
552
553**Wait for user response before proceeding to Gate 2.**
554
555#### Gate 2: PR Title & Description Review
556
5571. Extract PR title from `pr.md` first line:
558 * Remove leading `#` and whitespace
559 * Example: `# feat(scope): description` → `feat(scope): description`
560 * This cleaned title will be used for Azure DevOps PR creation
5612. Present complete PR description from `pr.md` body (after first line):
562 * Preserve all markdown formatting including headings with `#` markers
5633. Perform security/compliance analysis on `pr-reference.xml`:
564 * Customer information leaks (PII, customer data)
565 * Secrets or credentials (API keys, passwords, tokens)
566 * Non-compliant language (FIXME, WIP, etc in committed code)
567 * Unintended changes or accidental file inclusion
568 * Missing referenced files
569
570**Presentation Format**:
571
572```markdown
573## 📝 Pull Request Title & Description
574
575**Title**: [Generated title from pr.md]
576
577**Description**:
578[Complete PR description from pr.md with markdown preserved]
579
580**Security & Compliance Check**: [Results]
581
582Reply with "Continue", "Change title to: [new title]", or "Regenerate description".
583```
584
585**Wait for user response before proceeding to Gate 3.**
586
587#### Gate 3: Work Items Review
588
5891. If `${input:workItemIds}` was provided: Present those work items for confirmation.
5902. If work item was created in Phase 3a: Present the created work item for confirmation.
5913. If discovered in Phase 3: Present up to 10 highest similarity work items.
5924. For each work item provide:
593 * Work item ID and type
594 * Title
595 * Current state (for Closed items, add note: "Linking provides historical traceability")
596 * Similarity score (percentage) - or "Created for this PR" if from Phase 3a
597 * 1-2 sentence relevance reasoning
5985. For work items in Closed state, ask user to confirm if linking for historical traceability is desired.
599
600**Presentation Format**:
601
602```markdown
603## 🔗 Work Items to Link
604
605I found [count] work items that may relate to your changes:
606
6071. ADO-[ID] - [Type] - [State]: [Title] ([XX]% similarity)
608 Why: [1-2 sentence relevance]
609
610Reply with "Link [ID1], [ID2]", "Link all", or "Skip".
611```
612
613**Wait for user response and capture selections. Proceed to Gate 4.**
614
615#### Gate 4: Reviewers Review
616
6171. Present suggested reviewers from `reviewer-analysis.md`.
6182. Separate into Recommended and Additional categories based on contribution score.
6193. Provide contribution score and rationale for each.
620
621**Presentation Format**:
622
623```markdown
624## 👥 Suggested Reviewers
625
626Based on git history of changed files:
627
6281. [Name] ([email]) - [High/Medium] - [XX] commits: [Rationale]
6292. [Name] ([email]) - [Medium/Low] - [XX] commits: [Rationale]
630
631Reply with "Continue", "Add [email]", "Remove [email]", or "Skip".
632```
633
634**Wait for user response and capture selections. Proceed to Gate 5.**
635
636#### Gate 5: Final Summary & Signoff
637
6381. Build complete `handoff.md` with all user-confirmed selections.
6392. Present comprehensive summary of everything that will be created.
6403. Request final signoff before executing PR creation.
641
642**Presentation Format**:
643
644```markdown
645## ✨ Final Pull Request Summary
646
647**Pull Request**: [Title] | [source-branch] → [target-branch] | [count] files
648**Work Items**: [count] to link
649**Reviewers**: [count] total
650
651Reply with "Create PR", "Modify [aspect]", or "Cancel".
652```
653
654**Wait for explicit "Create PR" or "Approved" confirmation before proceeding to Phase 6.**
655
656### Phase 5 Modification Handling
657
658When user requests modifications at any gate, update the relevant planning file, log changes in `planning-log.md`, and re-present that gate for confirmation. Track modification count per gate; after 3+ iterations, suggest an alternative approach or pause.
659
660### Phase 6: Create Pull Request and Link Work Items
661
662Proceed after user gives explicit approval.
663
6641. Resolve repository and project IDs:
665 * Use `${input:repository}` directly if GUID format; otherwise call `mcp_ado_repo_get_repo_by_name_or_id` with project and repository name.
666 * Use `${input:adoProject}` directly if GUID; otherwise extract from `mcp_ado_search_workitem` response metadata.
667 * For GitHub-backed Azure DevOps projects where repository is not found: Verify the GitHub connection in Azure DevOps project settings (Project Settings → Repos → GitHub connections). The repository may require explicit configuration before appearing in ADO queries.
668 * Log both IDs in `planning-log.md`.
669
6702. Prepare branch references:
671 * Source: `refs/heads/${input:sourceBranch}` (or current branch)
672 * Target: Remove remote prefix from `${input:baseBranch}` and prepend `refs/heads/`. Examples:
673 * `origin/main` → `refs/heads/main`
674 * `upstream/develop` → `refs/heads/develop`
675 * `main` → `refs/heads/main`
676
6773. Create pull request using `mcp_ado_repo_create_pull_request` with `repositoryId`, `sourceRefName`, `targetRefName`, and `title` (from pr.md without leading #). Optionally include `description`, `isDraft`, and `labels`. The `workItems` parameter accepts space-separated IDs to link work items during creation, simplifying the workflow. Capture returned PR ID and URL.
678
6794. Link additional work items using `mcp_ado_wit_link_work_item_to_pull_request` for each selected work item not linked during creation. Requires `projectId` (GUID format), `repositoryId`, `pullRequestId`, and `workItemId`. For cross-project linking, include `pullRequestProjectId`. Log results in `planning-log.md`.
680
6815. Add reviewers using `mcp_ado_repo_update_pull_request_reviewers` with resolved identity GUIDs. All reviewers are added as optional by default. In no-gates mode, add top 2 by contribution score. Document unresolved reviewers for manual addition.
682
6836. Validate completion by reading `handoff.md` to verify checkboxes and confirming PR URL accessibility.
684
685## MCP Tool Reference
686
687```javascript
688// Resolve repository ID from name
689mcp_ado_repo_get_repo_by_name_or_id({
690 project: "<project-name-or-guid>",
691 repositoryNameOrId: "<repo-name>"
692})
693
694// Create PR (with optional work item and label linking)
695mcp_ado_repo_create_pull_request({
696 repositoryId: "<guid>",
697 sourceRefName: "refs/heads/<branch>",
698 targetRefName: "refs/heads/main",
699 title: "feat(scope): description",
700 description: "## Summary\n\nChanges...",
701 isDraft: false,
702 labels: ["label-name"], // Optional: add labels at creation
703 workItems: "1234 5678" // Optional: space-separated work item IDs
704})
705
706// Update PR (set autocomplete, merge strategy, labels)
707mcp_ado_repo_update_pull_request({
708 repositoryId: "<guid>",
709 pullRequestId: 1234,
710 autoComplete: true, // Enable autocomplete when policies pass
711 mergeStrategy: "Squash", // NoFastForward|Squash|Rebase|RebaseMerge
712 deleteSourceBranch: true, // Delete source after merge
713 transitionWorkItems: true // Transition linked work items
714})
715
716// Link work item (for cross-project, add pullRequestProjectId)
717mcp_ado_wit_link_work_item_to_pull_request({
718 projectId: "<project-guid>",
719 repositoryId: "<repo-guid>",
720 pullRequestId: 1234,
721 workItemId: 5678,
722 pullRequestProjectId: "<pr-project-guid>" // Optional: cross-project linking
723})
724
725// Resolve identity (requires activate_ado_identity_and_search_tools)
726mcp_ado_core_get_identity_ids({ searchFilter: "user@example.com" })
727
728// Add reviewers
729mcp_ado_repo_update_pull_request_reviewers({
730 repositoryId: "<guid>",
731 pullRequestId: 1234,
732 reviewerIds: ["<identity-guid-1>", "<identity-guid-2>"],
733 action: "add"
734})
735```
736
737### Phase 7: Deliver Final Recap
738
739Provide conversational summary covering PR creation status and URL, work items linked, reviewers status, planning workspace location, and next steps.
740
741```markdown
742## ✅ Pull Request Created Successfully
743
744**PR**: [PR ID] | [PR URL] | [Active|Draft]
745**Linked**: ADO-[ID], ADO-[ID]
746**Reviewers**: [Name] (added) | [Name] (manual)
747**Files**: `.copilot-tracking/pr/new/[branch]/`
748```
749
750## Error Recovery
751
752* **Phase 1**: PR reference generation fails → verify git state, branch existence, base branch validity
753* **Phase 3**: Too many/no work items → adjust similarity threshold or keyword groups; if still none, proceed to Phase 3a to create work item
754* **Phase 3a**: Work item creation fails → log error, inform user, proceed to Phase 4 without work item (user can link manually later)
755* **Phase 4**: Identity resolution fails → mark reviewer for manual addition via Azure DevOps UI
756* **Phase 6**: Repository/Project ID not found → search workspace config or request from user
757* **Phase 6**: PR creation fails → verify branch refs, permissions, no duplicate PR
758* **Phase 6**: Work item linking fails → verify work item exists, project ID is GUID format, PR created successfully
759* **Phase 6**: Reviewer addition fails → provide manual addition instructions with PR URL
760
761## Presentation Guidelines
762
763* Use markdown: **bold** for emphasis, emoji for visual clarity (✅, 📄, 🔍)
764* Present summaries before details; avoid information overload
765* Provide clear options with suggested responses
766* Confirm before irreversible actions
767
768## State Persistence & Recovery
769
770* Maintain `planning-log.md` after each major action
771* Update phase transitions in `planning-log.md`
772* If context is summarized:
773 1. Read all planning files from `.copilot-tracking/pr/new/<normalized-branch>/`
774 2. Rebuild context from `planning-log.md` current phase
775 3. Resume from last incomplete step
776 4. Inform user of recovery process
777
778## Repository-Specific Conventions
779
780When working in this repository:
781
782* Follow PR description format specified in Phase 2 (pr-file-format block)
783* Use conventional commit types in PR titles
784* Include component scope when applicable
785* Reference changed files for reviewer context
786* Link related documentation when available
787* Follow markdown linting rules per `.markdownlint.json`
788* Use natural, human-friendly language in PR descriptions
789* Group changes by significance and importance
790* Avoid speculating about benefits not stated in commits
791