prr-kit 1.0.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/LICENSE +21 -0
- package/README.md +226 -0
- package/docs/assets/banner.svg +179 -0
- package/package.json +60 -0
- package/src/core/agents/prr-master.agent.yaml +80 -0
- package/src/core/module.yaml +19 -0
- package/src/core/tasks/help.md +37 -0
- package/src/core/tasks/workflow.xml +22 -0
- package/src/core/workflows/party-mode/steps/step-01-load-reviewers.md +68 -0
- package/src/core/workflows/party-mode/steps/step-02-discussion.md +125 -0
- package/src/core/workflows/party-mode/workflow.md +35 -0
- package/src/prr/agents/architecture-reviewer.agent.yaml +45 -0
- package/src/prr/agents/general-reviewer.agent.yaml +48 -0
- package/src/prr/agents/performance-reviewer.agent.yaml +45 -0
- package/src/prr/agents/security-reviewer.agent.yaml +43 -0
- package/src/prr/data/review-types.csv +39 -0
- package/src/prr/module.yaml +38 -0
- package/src/prr/workflows/0-setup/collect-project-context/steps/step-01-scan-configs.md +106 -0
- package/src/prr/workflows/0-setup/collect-project-context/steps/step-02-extract-rules.md +131 -0
- package/src/prr/workflows/0-setup/collect-project-context/steps/step-03-ask-context.md +194 -0
- package/src/prr/workflows/0-setup/collect-project-context/steps/step-04-save-context.md +161 -0
- package/src/prr/workflows/0-setup/collect-project-context/workflow.md +58 -0
- package/src/prr/workflows/1-discover/select-pr/steps/step-01-fetch.md +68 -0
- package/src/prr/workflows/1-discover/select-pr/steps/step-02-list-branches.md +95 -0
- package/src/prr/workflows/1-discover/select-pr/steps/step-03-select.md +127 -0
- package/src/prr/workflows/1-discover/select-pr/steps/step-04-load-diff.md +79 -0
- package/src/prr/workflows/1-discover/select-pr/steps/step-05-confirm.md +76 -0
- package/src/prr/workflows/1-discover/select-pr/workflow.md +36 -0
- package/src/prr/workflows/2-analyze/describe-pr/steps/step-01-load-context.md +37 -0
- package/src/prr/workflows/2-analyze/describe-pr/steps/step-02-classify.md +50 -0
- package/src/prr/workflows/2-analyze/describe-pr/steps/step-03-walkthrough.md +41 -0
- package/src/prr/workflows/2-analyze/describe-pr/steps/step-04-output.md +50 -0
- package/src/prr/workflows/2-analyze/describe-pr/templates/pr-description.template.md +51 -0
- package/src/prr/workflows/2-analyze/describe-pr/workflow.md +28 -0
- package/src/prr/workflows/3-review/architecture-review/checklist.md +22 -0
- package/src/prr/workflows/3-review/architecture-review/instructions.xml +68 -0
- package/src/prr/workflows/3-review/architecture-review/workflow.yaml +18 -0
- package/src/prr/workflows/3-review/general-review/checklist.md +23 -0
- package/src/prr/workflows/3-review/general-review/instructions.xml +68 -0
- package/src/prr/workflows/3-review/general-review/workflow.yaml +18 -0
- package/src/prr/workflows/3-review/performance-review/checklist.md +22 -0
- package/src/prr/workflows/3-review/performance-review/instructions.xml +68 -0
- package/src/prr/workflows/3-review/performance-review/workflow.yaml +18 -0
- package/src/prr/workflows/3-review/security-review/checklist.md +25 -0
- package/src/prr/workflows/3-review/security-review/data/owasp-checklist.csv +19 -0
- package/src/prr/workflows/3-review/security-review/instructions.xml +70 -0
- package/src/prr/workflows/3-review/security-review/workflow.yaml +19 -0
- package/src/prr/workflows/4-improve/improve-code/checklist.md +18 -0
- package/src/prr/workflows/4-improve/improve-code/instructions.xml +59 -0
- package/src/prr/workflows/4-improve/improve-code/workflow.yaml +18 -0
- package/src/prr/workflows/5-ask/ask-code/steps/step-01-load-context.md +37 -0
- package/src/prr/workflows/5-ask/ask-code/steps/step-02-answer.md +36 -0
- package/src/prr/workflows/5-ask/ask-code/workflow.md +31 -0
- package/src/prr/workflows/6-report/generate-report/steps/step-01-collect.md +42 -0
- package/src/prr/workflows/6-report/generate-report/steps/step-02-organize.md +38 -0
- package/src/prr/workflows/6-report/generate-report/steps/step-03-write.md +44 -0
- package/src/prr/workflows/6-report/generate-report/templates/review-report.template.md +78 -0
- package/src/prr/workflows/6-report/generate-report/workflow.md +26 -0
- package/src/prr/workflows/6-report/post-comments/steps/step-01-format.md +166 -0
- package/src/prr/workflows/6-report/post-comments/steps/step-02-post.md +97 -0
- package/src/prr/workflows/6-report/post-comments/workflow.md +45 -0
- package/src/prr/workflows/quick/workflow.md +244 -0
- package/tools/cli/commands/install.js +66 -0
- package/tools/cli/commands/status.js +36 -0
- package/tools/cli/commands/uninstall.js +38 -0
- package/tools/cli/installers/lib/core/config-collector.js +47 -0
- package/tools/cli/installers/lib/core/detector.js +46 -0
- package/tools/cli/installers/lib/core/installer.js +162 -0
- package/tools/cli/installers/lib/core/manifest-generator.js +172 -0
- package/tools/cli/installers/lib/core/manifest.js +62 -0
- package/tools/cli/installers/lib/ide/_base-ide.js +36 -0
- package/tools/cli/installers/lib/ide/_config-driven.js +167 -0
- package/tools/cli/installers/lib/ide/manager.js +97 -0
- package/tools/cli/installers/lib/ide/platform-codes.yaml +76 -0
- package/tools/cli/installers/lib/ide/shared/path-utils.js +11 -0
- package/tools/cli/installers/lib/ide/templates/combined/default-agent.md +16 -0
- package/tools/cli/installers/lib/ide/templates/combined/default-workflow.md +7 -0
- package/tools/cli/installers/lib/ide/templates/combined/windsurf-workflow.md +5 -0
- package/tools/cli/lib/agent/compiler.js +123 -0
- package/tools/cli/lib/agent/template-engine.js +73 -0
- package/tools/cli/lib/cli-utils.js +32 -0
- package/tools/cli/lib/prompts.js +15 -0
- package/tools/cli/lib/ui.js +132 -0
- package/tools/cli/lib/xml-utils.js +24 -0
- package/tools/cli/prr-cli.js +36 -0
- package/tools/prr-npx-wrapper.js +6 -0
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
---
|
|
2
|
+
name: "step-02-organize"
|
|
3
|
+
description: "Organize findings by severity and category for the report"
|
|
4
|
+
nextStepFile: "./step-03-write.md"
|
|
5
|
+
---
|
|
6
|
+
|
|
7
|
+
# Step 2: Organize Findings
|
|
8
|
+
|
|
9
|
+
## Sequence of Instructions
|
|
10
|
+
|
|
11
|
+
### 1. Sort by Severity
|
|
12
|
+
|
|
13
|
+
Order: 🔴 Blockers/Critical → 🟡 Warnings/High → 🟡 Medium → 🟢 Suggestions/Low → 📌 Questions
|
|
14
|
+
|
|
15
|
+
### 2. Group by Category
|
|
16
|
+
|
|
17
|
+
Within each severity level, group by review category:
|
|
18
|
+
- 🔒 Security
|
|
19
|
+
- ⚡ Performance
|
|
20
|
+
- 🏗️ Architecture
|
|
21
|
+
- 👁️ General Quality
|
|
22
|
+
- 💡 Improvements
|
|
23
|
+
|
|
24
|
+
### 3. Create Executive Summary
|
|
25
|
+
|
|
26
|
+
Write 3-5 bullet points summarizing the overall review:
|
|
27
|
+
- Overall quality assessment (1 sentence)
|
|
28
|
+
- Highest priority issues to address
|
|
29
|
+
- Positive findings (good practices found)
|
|
30
|
+
- Recommendation: approved / needs changes / request changes
|
|
31
|
+
|
|
32
|
+
### 4. Identify Files with Multiple Issues
|
|
33
|
+
|
|
34
|
+
List files that have 3+ findings — these may need more significant rework.
|
|
35
|
+
|
|
36
|
+
### 5. Load Next Step
|
|
37
|
+
|
|
38
|
+
Add `step-02-organize` to `stepsCompleted`. Load: `{nextStepFile}`
|
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
---
|
|
2
|
+
name: "step-03-write"
|
|
3
|
+
description: "Write the final review report to file"
|
|
4
|
+
outputFile: "{review_output}/review-report-{pr_branch}-{date}.md"
|
|
5
|
+
templateFile: "../templates/review-report.template.md"
|
|
6
|
+
---
|
|
7
|
+
|
|
8
|
+
# Step 3: Write Report
|
|
9
|
+
|
|
10
|
+
## Sequence of Instructions
|
|
11
|
+
|
|
12
|
+
### 1. Generate Report
|
|
13
|
+
|
|
14
|
+
Using `{templateFile}`, write the complete review report to `{outputFile}`.
|
|
15
|
+
|
|
16
|
+
The report includes:
|
|
17
|
+
- PR metadata and review summary
|
|
18
|
+
- Executive summary with overall verdict
|
|
19
|
+
- All findings organized by severity and category
|
|
20
|
+
- Files with multiple issues highlighted
|
|
21
|
+
- Recommended actions (must-fix vs nice-to-have)
|
|
22
|
+
|
|
23
|
+
### 2. Display Completion
|
|
24
|
+
|
|
25
|
+
```
|
|
26
|
+
✅ Review Report Generated!
|
|
27
|
+
━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
|
|
28
|
+
📄 File: {outputFile}
|
|
29
|
+
|
|
30
|
+
Summary:
|
|
31
|
+
🔴 Blockers: {blocker_count}
|
|
32
|
+
🟡 Warnings: {warning_count}
|
|
33
|
+
🟢 Suggestions: {suggestion_count}
|
|
34
|
+
📌 Questions: {question_count}
|
|
35
|
+
|
|
36
|
+
Verdict: {verdict}
|
|
37
|
+
━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
|
|
38
|
+
|
|
39
|
+
Next steps:
|
|
40
|
+
[PC] Post Comments — post these findings to GitHub PR
|
|
41
|
+
or share the report file directly with the PR author
|
|
42
|
+
```
|
|
43
|
+
|
|
44
|
+
**Workflow complete.** Return to agent menu.
|
|
@@ -0,0 +1,78 @@
|
|
|
1
|
+
---
|
|
2
|
+
pr_branch: "{{target_branch}}"
|
|
3
|
+
base_branch: "{{base_branch}}"
|
|
4
|
+
pr_number: "{{pr_number}}"
|
|
5
|
+
date: "{{date}}"
|
|
6
|
+
verdict: "{{verdict}}"
|
|
7
|
+
reviews_completed:
|
|
8
|
+
{{reviews_completed_list}}
|
|
9
|
+
stepsCompleted: []
|
|
10
|
+
---
|
|
11
|
+
|
|
12
|
+
# Code Review Report: {{pr_title}}
|
|
13
|
+
|
|
14
|
+
**PR:** `{{target_branch}}` → `{{base_branch}}`
|
|
15
|
+
{{#if pr_number}}**GitHub PR #{{pr_number}}** | {{/if}}**Date:** {{date}} | **Reviewer:** {{user_name}}
|
|
16
|
+
|
|
17
|
+
---
|
|
18
|
+
|
|
19
|
+
## Executive Summary
|
|
20
|
+
|
|
21
|
+
{{executive_summary}}
|
|
22
|
+
|
|
23
|
+
**Verdict:** {{verdict}}
|
|
24
|
+
|
|
25
|
+
| Category | 🔴 Blockers | 🟡 Warnings | 🟢 Suggestions |
|
|
26
|
+
|----------|------------|------------|----------------|
|
|
27
|
+
| 🔒 Security | {{security_blockers}} | {{security_warnings}} | {{security_suggestions}} |
|
|
28
|
+
| ⚡ Performance | {{perf_blockers}} | {{perf_warnings}} | {{perf_suggestions}} |
|
|
29
|
+
| 🏗️ Architecture | {{arch_blockers}} | {{arch_warnings}} | {{arch_suggestions}} |
|
|
30
|
+
| 👁️ General | {{general_blockers}} | {{general_warnings}} | {{general_suggestions}} |
|
|
31
|
+
| **Total** | **{{total_blockers}}** | **{{total_warnings}}** | **{{total_suggestions}}** |
|
|
32
|
+
|
|
33
|
+
---
|
|
34
|
+
|
|
35
|
+
## 🔴 Blockers — Must Fix Before Merge
|
|
36
|
+
|
|
37
|
+
{{blockers_section}}
|
|
38
|
+
|
|
39
|
+
---
|
|
40
|
+
|
|
41
|
+
## 🟡 Warnings — Should Fix
|
|
42
|
+
|
|
43
|
+
{{warnings_section}}
|
|
44
|
+
|
|
45
|
+
---
|
|
46
|
+
|
|
47
|
+
## 🟢 Suggestions — Nice to Have
|
|
48
|
+
|
|
49
|
+
{{suggestions_section}}
|
|
50
|
+
|
|
51
|
+
---
|
|
52
|
+
|
|
53
|
+
## 📌 Questions for Author
|
|
54
|
+
|
|
55
|
+
{{questions_section}}
|
|
56
|
+
|
|
57
|
+
---
|
|
58
|
+
|
|
59
|
+
## 💡 Code Improvement Suggestions
|
|
60
|
+
|
|
61
|
+
{{improvements_section}}
|
|
62
|
+
|
|
63
|
+
---
|
|
64
|
+
|
|
65
|
+
## Files with Multiple Issues
|
|
66
|
+
|
|
67
|
+
{{files_with_issues}}
|
|
68
|
+
|
|
69
|
+
---
|
|
70
|
+
|
|
71
|
+
## ✅ Positive Observations
|
|
72
|
+
|
|
73
|
+
{{positive_observations}}
|
|
74
|
+
|
|
75
|
+
---
|
|
76
|
+
|
|
77
|
+
*Generated by PR Review Framework*
|
|
78
|
+
*Reviews completed: {{reviews_completed}}*
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
---
|
|
2
|
+
name: generate-report
|
|
3
|
+
description: "Compile all review findings into a structured Markdown review report"
|
|
4
|
+
main_config: "{project-root}/_prr/prr/config.yaml"
|
|
5
|
+
nextStep: "./steps/step-01-collect.md"
|
|
6
|
+
---
|
|
7
|
+
|
|
8
|
+
# Generate Report Workflow
|
|
9
|
+
|
|
10
|
+
**Goal:** Collect all findings from completed review workflows and compile them into a single, well-structured Markdown review report.
|
|
11
|
+
|
|
12
|
+
## WORKFLOW ARCHITECTURE
|
|
13
|
+
|
|
14
|
+
3-step process:
|
|
15
|
+
1. Collect findings from all completed review output files
|
|
16
|
+
2. Organize by severity (🔴 → 🟡 → 🟢) and category
|
|
17
|
+
3. Write final report using the review report template
|
|
18
|
+
|
|
19
|
+
## INITIALIZATION
|
|
20
|
+
|
|
21
|
+
Load config from `{main_config}`.
|
|
22
|
+
Load PR context from `{review_output}/current-pr-context.yaml`.
|
|
23
|
+
|
|
24
|
+
## EXECUTION
|
|
25
|
+
|
|
26
|
+
Read fully and follow: `{nextStep}`
|
|
@@ -0,0 +1,166 @@
|
|
|
1
|
+
---
|
|
2
|
+
name: "step-01-format"
|
|
3
|
+
description: "Parse findings and build platform-specific comment payload"
|
|
4
|
+
nextStepFile: "./step-02-post.md"
|
|
5
|
+
---
|
|
6
|
+
|
|
7
|
+
# Step 1: Build Comment Payload
|
|
8
|
+
|
|
9
|
+
## Sequence of Instructions
|
|
10
|
+
|
|
11
|
+
### 1. Check Prerequisites
|
|
12
|
+
|
|
13
|
+
Verify `{review_output}/current-pr-context.yaml` exists and contains:
|
|
14
|
+
- `pr_number` — if missing, show: `❌ No PR number found. Run [SP] Select PR first.`
|
|
15
|
+
- `target_branch`, `base_branch`
|
|
16
|
+
|
|
17
|
+
Verify platform CLI is available:
|
|
18
|
+
|
|
19
|
+
| Platform | Check command | Error message |
|
|
20
|
+
|----------|--------------|---------------|
|
|
21
|
+
| github | `gh auth status` | `❌ Run: gh auth login` |
|
|
22
|
+
| gitlab | `glab auth status` | `❌ Run: glab auth login` |
|
|
23
|
+
| azure | `az account show` | `❌ Run: az login && az devops configure` |
|
|
24
|
+
| bitbucket | check env `BB_TOKEN` or `~/.config/bb` | `❌ Set Bitbucket credentials` |
|
|
25
|
+
| none | — | show: `ℹ️ No platform configured — findings saved to report only.` then stop |
|
|
26
|
+
|
|
27
|
+
### 2. Get Head Commit SHA
|
|
28
|
+
|
|
29
|
+
**GitHub / GitLab / Bitbucket:**
|
|
30
|
+
```bash
|
|
31
|
+
git -C {target_repo} rev-parse origin/{selected_branch}
|
|
32
|
+
```
|
|
33
|
+
Or use `{pr_head_sha}` if already stored from select-pr step.
|
|
34
|
+
|
|
35
|
+
**Azure DevOps:**
|
|
36
|
+
```bash
|
|
37
|
+
az repos pr show --id {pr_number} --query lastMergeSourceCommit.commitId -o tsv
|
|
38
|
+
```
|
|
39
|
+
|
|
40
|
+
Store as `{commit_sha}`.
|
|
41
|
+
|
|
42
|
+
### 3. Load Review Report
|
|
43
|
+
|
|
44
|
+
Find the latest report in `{review_output}/review-*.md`.
|
|
45
|
+
Sort by modification time, take the most recent.
|
|
46
|
+
|
|
47
|
+
### 4. Parse All Findings
|
|
48
|
+
|
|
49
|
+
Scan the report and extract every finding:
|
|
50
|
+
- `severity`: 🔴 Blocker / 🟡 Warning / 🟢 Suggestion / 📌 Question
|
|
51
|
+
- `category`: security / performance / architecture / general
|
|
52
|
+
- `file_path`: relative path (e.g. `src/auth/login.js`) — null if not specified
|
|
53
|
+
- `line_number`: integer — null if not specified
|
|
54
|
+
- `description`: the issue text
|
|
55
|
+
- `suggested_fix`: fix/suggestion text
|
|
56
|
+
|
|
57
|
+
**Classify:**
|
|
58
|
+
- **Inline candidates**: `file_path` and `line_number` both present
|
|
59
|
+
- **Fallback findings**: no file or line reference
|
|
60
|
+
|
|
61
|
+
Limit inline comments to 30 max: include all 🔴 Blockers first, then 🟡 Warnings, then 🟢 Suggestions. Move overflow to fallback.
|
|
62
|
+
|
|
63
|
+
### 5. Format Comment Bodies
|
|
64
|
+
|
|
65
|
+
**🔴 Blocker:**
|
|
66
|
+
```
|
|
67
|
+
🔴 **[BLOCKER]** {emoji} {description}
|
|
68
|
+
**Risk:** {what could go wrong}
|
|
69
|
+
**Fix:** {suggested_fix}
|
|
70
|
+
```
|
|
71
|
+
|
|
72
|
+
**🟡 Warning:**
|
|
73
|
+
```
|
|
74
|
+
🟡 **[WARNING]** {emoji} {description}
|
|
75
|
+
**Why it matters:** {explanation}
|
|
76
|
+
**Suggestion:** {suggested_fix}
|
|
77
|
+
```
|
|
78
|
+
|
|
79
|
+
**🟢 Suggestion:**
|
|
80
|
+
```
|
|
81
|
+
🟢 **[SUGGESTION]** {description}
|
|
82
|
+
{suggested_fix}
|
|
83
|
+
```
|
|
84
|
+
|
|
85
|
+
Category emojis: 🔒 security · ⚡ performance · 🏗️ architecture · 👁️ general
|
|
86
|
+
|
|
87
|
+
### 6. Build Summary Body
|
|
88
|
+
|
|
89
|
+
```markdown
|
|
90
|
+
## 🔍 AI Code Review
|
|
91
|
+
|
|
92
|
+
**PR:** `{selected_branch}` → `{base_branch}` | **Date:** {date} | **Reviewer:** {user_name}
|
|
93
|
+
|
|
94
|
+
**Verdict:** {verdict}
|
|
95
|
+
|
|
96
|
+
| Category | 🔴 | 🟡 | 🟢 |
|
|
97
|
+
|----------|----|----|----|
|
|
98
|
+
| 🔒 Security | {n} | {n} | {n} |
|
|
99
|
+
| ⚡ Performance | {n} | {n} | {n} |
|
|
100
|
+
| 🏗️ Architecture | {n} | {n} | {n} |
|
|
101
|
+
| 👁️ General | {n} | {n} | {n} |
|
|
102
|
+
|
|
103
|
+
### Executive Summary
|
|
104
|
+
{bullets}
|
|
105
|
+
|
|
106
|
+
{fallback_findings_section}
|
|
107
|
+
|
|
108
|
+
---
|
|
109
|
+
*{inline_count} inline comments on code lines*
|
|
110
|
+
```
|
|
111
|
+
|
|
112
|
+
Verdict logic: any 🔴 → `REQUEST_CHANGES` / only 🟡 → `COMMENT` / none → `APPROVE`
|
|
113
|
+
|
|
114
|
+
### 7. Build Platform Payload
|
|
115
|
+
|
|
116
|
+
**GitHub** — single JSON file for Reviews API:
|
|
117
|
+
```json
|
|
118
|
+
{
|
|
119
|
+
"commit_id": "{commit_sha}",
|
|
120
|
+
"body": "{summary_body}",
|
|
121
|
+
"event": "REQUEST_CHANGES|COMMENT|APPROVE",
|
|
122
|
+
"comments": [
|
|
123
|
+
{ "path": "{file_path}", "line": {line_number}, "side": "RIGHT", "body": "{body}" }
|
|
124
|
+
]
|
|
125
|
+
}
|
|
126
|
+
```
|
|
127
|
+
Write to `{review_output}/.prr-payload.json`.
|
|
128
|
+
|
|
129
|
+
**GitLab** — separate JSON per inline comment:
|
|
130
|
+
```json
|
|
131
|
+
{ "body": "{body}", "position": { "base_sha": "{base_sha}", "head_sha": "{commit_sha}",
|
|
132
|
+
"start_sha": "{base_sha}", "position_type": "text",
|
|
133
|
+
"new_path": "{file_path}", "new_line": {line_number} } }
|
|
134
|
+
```
|
|
135
|
+
Write each as `{review_output}/.prr-payload-{n}.json`. Write summary as `.prr-summary.md`.
|
|
136
|
+
|
|
137
|
+
**Azure DevOps** — thread per inline comment:
|
|
138
|
+
```json
|
|
139
|
+
{ "comments": [{ "parentCommentId": 0, "content": "{body}", "commentType": 1 }],
|
|
140
|
+
"threadContext": { "filePath": "{file_path}",
|
|
141
|
+
"rightFileStart": { "line": {line_number}, "offset": 1 },
|
|
142
|
+
"rightFileEnd": { "line": {line_number}, "offset": 1 } },
|
|
143
|
+
"status": "active" }
|
|
144
|
+
```
|
|
145
|
+
Write each as `{review_output}/.prr-thread-{n}.json`.
|
|
146
|
+
|
|
147
|
+
**Bitbucket** — inline comment per finding:
|
|
148
|
+
```json
|
|
149
|
+
{ "content": { "raw": "{body}" },
|
|
150
|
+
"inline": { "to": {line_number}, "path": "{file_path}" } }
|
|
151
|
+
```
|
|
152
|
+
Write each as `{review_output}/.prr-bb-{n}.json`.
|
|
153
|
+
|
|
154
|
+
### 8. Display Preview
|
|
155
|
+
|
|
156
|
+
```
|
|
157
|
+
📋 Payload ready:
|
|
158
|
+
Platform: {active_platform}
|
|
159
|
+
Inline comments: {inline_count}
|
|
160
|
+
Fallback comments: {fallback_count}
|
|
161
|
+
Verdict: {event}
|
|
162
|
+
```
|
|
163
|
+
|
|
164
|
+
### 9. Load Next Step
|
|
165
|
+
|
|
166
|
+
Add `step-01-format` to `stepsCompleted`. Load: `{nextStepFile}`
|
|
@@ -0,0 +1,97 @@
|
|
|
1
|
+
---
|
|
2
|
+
name: "step-02-post"
|
|
3
|
+
description: "Post comments via platform CLI/API, verify, clean up"
|
|
4
|
+
---
|
|
5
|
+
|
|
6
|
+
# Step 2: Post to Platform
|
|
7
|
+
|
|
8
|
+
## Sequence of Instructions
|
|
9
|
+
|
|
10
|
+
### 1. Post Based on Platform
|
|
11
|
+
|
|
12
|
+
**GitHub:**
|
|
13
|
+
```bash
|
|
14
|
+
gh api repos/{platform_repo}/pulls/{pr_number}/reviews \
|
|
15
|
+
--method POST \
|
|
16
|
+
--header "Accept: application/vnd.github+json" \
|
|
17
|
+
--input {review_output}/.prr-payload.json
|
|
18
|
+
```
|
|
19
|
+
|
|
20
|
+
Handle 422 (line not in diff): remove the offending inline comment from payload, add to summary body, retry.
|
|
21
|
+
|
|
22
|
+
**GitLab:**
|
|
23
|
+
```bash
|
|
24
|
+
# Post summary as MR note
|
|
25
|
+
glab mr note {pr_number} --repo {platform_repo} --message "$(cat {review_output}/.prr-summary.md)"
|
|
26
|
+
|
|
27
|
+
# Post each inline comment
|
|
28
|
+
for payload in {review_output}/.prr-payload-*.json; do
|
|
29
|
+
glab api projects/{encoded_repo}/merge_requests/{pr_number}/discussions \
|
|
30
|
+
--method POST --input "$payload"
|
|
31
|
+
done
|
|
32
|
+
```
|
|
33
|
+
Where `{encoded_repo}` = `{platform_repo}` with `/` replaced by `%2F`.
|
|
34
|
+
|
|
35
|
+
**Azure DevOps:**
|
|
36
|
+
```bash
|
|
37
|
+
# Post summary as PR comment
|
|
38
|
+
az repos pr comment add --id {pr_number} --comment "$(cat {review_output}/.prr-summary.md)"
|
|
39
|
+
|
|
40
|
+
# Post each inline thread
|
|
41
|
+
for payload in {review_output}/.prr-thread-*.json; do
|
|
42
|
+
az repos pr thread create --id {pr_number} \
|
|
43
|
+
--template-file "$payload"
|
|
44
|
+
done
|
|
45
|
+
```
|
|
46
|
+
|
|
47
|
+
**Bitbucket:**
|
|
48
|
+
```bash
|
|
49
|
+
# Post summary
|
|
50
|
+
curl -s -X POST \
|
|
51
|
+
"https://api.bitbucket.org/2.0/repositories/{platform_repo}/pullrequests/{pr_number}/comments" \
|
|
52
|
+
-H "Authorization: Bearer {BB_TOKEN}" \
|
|
53
|
+
-H "Content-Type: application/json" \
|
|
54
|
+
-d "{\"content\": {\"raw\": \"$(cat {review_output}/.prr-summary.md)\"}}"
|
|
55
|
+
|
|
56
|
+
# Post each inline comment
|
|
57
|
+
for payload in {review_output}/.prr-bb-*.json; do
|
|
58
|
+
curl -s -X POST \
|
|
59
|
+
"https://api.bitbucket.org/2.0/repositories/{platform_repo}/pullrequests/{pr_number}/comments" \
|
|
60
|
+
-H "Authorization: Bearer {BB_TOKEN}" \
|
|
61
|
+
-H "Content-Type: application/json" \
|
|
62
|
+
-d "@$payload"
|
|
63
|
+
done
|
|
64
|
+
```
|
|
65
|
+
|
|
66
|
+
### 2. Verify
|
|
67
|
+
|
|
68
|
+
Confirm the post was successful by checking for a `200` or `201` response.
|
|
69
|
+
|
|
70
|
+
**GitHub:** `gh pr view {pr_number} --repo {platform_repo} --json reviews --jq '.reviews[-1].state'`
|
|
71
|
+
**GitLab:** `glab mr view {pr_number} --repo {platform_repo} --output json | jq '.user_notes_count'`
|
|
72
|
+
**Azure:** `az repos pr thread list --id {pr_number} --query "length(@)"`
|
|
73
|
+
**Bitbucket:** check response `id` field from the post
|
|
74
|
+
|
|
75
|
+
### 3. Clean Up Temp Files
|
|
76
|
+
|
|
77
|
+
```bash
|
|
78
|
+
rm -f {review_output}/.prr-payload*.json \
|
|
79
|
+
{review_output}/.prr-summary.md \
|
|
80
|
+
{review_output}/.prr-thread-*.json \
|
|
81
|
+
{review_output}/.prr-bb-*.json
|
|
82
|
+
```
|
|
83
|
+
|
|
84
|
+
### 4. Display Completion
|
|
85
|
+
|
|
86
|
+
```
|
|
87
|
+
✅ Review Posted!
|
|
88
|
+
━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
|
|
89
|
+
Platform: {active_platform}
|
|
90
|
+
PR/MR #: {pr_number}
|
|
91
|
+
Inline: {inline_count} comments on code lines
|
|
92
|
+
Verdict: {verdict_label}
|
|
93
|
+
Link: {pr_url}
|
|
94
|
+
━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
|
|
95
|
+
```
|
|
96
|
+
|
|
97
|
+
**Workflow complete.** Return to agent menu.
|
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
---
|
|
2
|
+
name: post-comments
|
|
3
|
+
description: "Post review findings as inline comments on the PR/MR via platform CLI"
|
|
4
|
+
main_config: "{project-root}/_prr/prr/config.yaml"
|
|
5
|
+
nextStep: "./steps/step-01-format.md"
|
|
6
|
+
---
|
|
7
|
+
|
|
8
|
+
# Post Comments Workflow
|
|
9
|
+
|
|
10
|
+
**Goal:** Post review findings as **inline comments on the exact code lines** of the PR/MR, plus a formal summary — using the appropriate platform CLI.
|
|
11
|
+
|
|
12
|
+
## SUPPORTED PLATFORMS
|
|
13
|
+
|
|
14
|
+
| Platform | Tool | Inline Comments | Summary Review |
|
|
15
|
+
|----------|------|----------------|----------------|
|
|
16
|
+
| GitHub | `gh api` | ✅ GitHub Reviews API | ✅ |
|
|
17
|
+
| GitLab | `glab` / GitLab API | ✅ MR note threads | ✅ |
|
|
18
|
+
| Azure DevOps | `az devops` | ✅ PR thread comments | ✅ |
|
|
19
|
+
| Bitbucket | Bitbucket REST API | ✅ inline comments | ✅ |
|
|
20
|
+
| None / local | — | ❌ not available | saves to file |
|
|
21
|
+
|
|
22
|
+
## WORKFLOW ARCHITECTURE
|
|
23
|
+
|
|
24
|
+
2-step process:
|
|
25
|
+
1. Parse findings → extract file/line → build platform-specific payload
|
|
26
|
+
2. Post via platform CLI/API → verify → clean up
|
|
27
|
+
|
|
28
|
+
## PREREQUISITES
|
|
29
|
+
|
|
30
|
+
Depends on `{active_platform}`:
|
|
31
|
+
- **GitHub**: `gh` CLI authenticated — `gh auth status`
|
|
32
|
+
- **GitLab**: `glab` CLI authenticated — `glab auth status`
|
|
33
|
+
- **Azure DevOps**: `az` CLI with `azure-devops` extension — `az devops configure`
|
|
34
|
+
- **Bitbucket**: Bitbucket App Password set in `~/.config/bb` or env vars
|
|
35
|
+
- **None**: no prerequisites — saves report only
|
|
36
|
+
|
|
37
|
+
## INITIALIZATION
|
|
38
|
+
|
|
39
|
+
Load config from `{main_config}`.
|
|
40
|
+
Load PR context from `{review_output}/current-pr-context.yaml`.
|
|
41
|
+
Use `{active_platform}` (or detect from `{platform}` config).
|
|
42
|
+
|
|
43
|
+
## EXECUTION
|
|
44
|
+
|
|
45
|
+
Read fully and follow: `{nextStep}`
|