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.
Files changed (86) hide show
  1. package/LICENSE +21 -0
  2. package/README.md +226 -0
  3. package/docs/assets/banner.svg +179 -0
  4. package/package.json +60 -0
  5. package/src/core/agents/prr-master.agent.yaml +80 -0
  6. package/src/core/module.yaml +19 -0
  7. package/src/core/tasks/help.md +37 -0
  8. package/src/core/tasks/workflow.xml +22 -0
  9. package/src/core/workflows/party-mode/steps/step-01-load-reviewers.md +68 -0
  10. package/src/core/workflows/party-mode/steps/step-02-discussion.md +125 -0
  11. package/src/core/workflows/party-mode/workflow.md +35 -0
  12. package/src/prr/agents/architecture-reviewer.agent.yaml +45 -0
  13. package/src/prr/agents/general-reviewer.agent.yaml +48 -0
  14. package/src/prr/agents/performance-reviewer.agent.yaml +45 -0
  15. package/src/prr/agents/security-reviewer.agent.yaml +43 -0
  16. package/src/prr/data/review-types.csv +39 -0
  17. package/src/prr/module.yaml +38 -0
  18. package/src/prr/workflows/0-setup/collect-project-context/steps/step-01-scan-configs.md +106 -0
  19. package/src/prr/workflows/0-setup/collect-project-context/steps/step-02-extract-rules.md +131 -0
  20. package/src/prr/workflows/0-setup/collect-project-context/steps/step-03-ask-context.md +194 -0
  21. package/src/prr/workflows/0-setup/collect-project-context/steps/step-04-save-context.md +161 -0
  22. package/src/prr/workflows/0-setup/collect-project-context/workflow.md +58 -0
  23. package/src/prr/workflows/1-discover/select-pr/steps/step-01-fetch.md +68 -0
  24. package/src/prr/workflows/1-discover/select-pr/steps/step-02-list-branches.md +95 -0
  25. package/src/prr/workflows/1-discover/select-pr/steps/step-03-select.md +127 -0
  26. package/src/prr/workflows/1-discover/select-pr/steps/step-04-load-diff.md +79 -0
  27. package/src/prr/workflows/1-discover/select-pr/steps/step-05-confirm.md +76 -0
  28. package/src/prr/workflows/1-discover/select-pr/workflow.md +36 -0
  29. package/src/prr/workflows/2-analyze/describe-pr/steps/step-01-load-context.md +37 -0
  30. package/src/prr/workflows/2-analyze/describe-pr/steps/step-02-classify.md +50 -0
  31. package/src/prr/workflows/2-analyze/describe-pr/steps/step-03-walkthrough.md +41 -0
  32. package/src/prr/workflows/2-analyze/describe-pr/steps/step-04-output.md +50 -0
  33. package/src/prr/workflows/2-analyze/describe-pr/templates/pr-description.template.md +51 -0
  34. package/src/prr/workflows/2-analyze/describe-pr/workflow.md +28 -0
  35. package/src/prr/workflows/3-review/architecture-review/checklist.md +22 -0
  36. package/src/prr/workflows/3-review/architecture-review/instructions.xml +68 -0
  37. package/src/prr/workflows/3-review/architecture-review/workflow.yaml +18 -0
  38. package/src/prr/workflows/3-review/general-review/checklist.md +23 -0
  39. package/src/prr/workflows/3-review/general-review/instructions.xml +68 -0
  40. package/src/prr/workflows/3-review/general-review/workflow.yaml +18 -0
  41. package/src/prr/workflows/3-review/performance-review/checklist.md +22 -0
  42. package/src/prr/workflows/3-review/performance-review/instructions.xml +68 -0
  43. package/src/prr/workflows/3-review/performance-review/workflow.yaml +18 -0
  44. package/src/prr/workflows/3-review/security-review/checklist.md +25 -0
  45. package/src/prr/workflows/3-review/security-review/data/owasp-checklist.csv +19 -0
  46. package/src/prr/workflows/3-review/security-review/instructions.xml +70 -0
  47. package/src/prr/workflows/3-review/security-review/workflow.yaml +19 -0
  48. package/src/prr/workflows/4-improve/improve-code/checklist.md +18 -0
  49. package/src/prr/workflows/4-improve/improve-code/instructions.xml +59 -0
  50. package/src/prr/workflows/4-improve/improve-code/workflow.yaml +18 -0
  51. package/src/prr/workflows/5-ask/ask-code/steps/step-01-load-context.md +37 -0
  52. package/src/prr/workflows/5-ask/ask-code/steps/step-02-answer.md +36 -0
  53. package/src/prr/workflows/5-ask/ask-code/workflow.md +31 -0
  54. package/src/prr/workflows/6-report/generate-report/steps/step-01-collect.md +42 -0
  55. package/src/prr/workflows/6-report/generate-report/steps/step-02-organize.md +38 -0
  56. package/src/prr/workflows/6-report/generate-report/steps/step-03-write.md +44 -0
  57. package/src/prr/workflows/6-report/generate-report/templates/review-report.template.md +78 -0
  58. package/src/prr/workflows/6-report/generate-report/workflow.md +26 -0
  59. package/src/prr/workflows/6-report/post-comments/steps/step-01-format.md +166 -0
  60. package/src/prr/workflows/6-report/post-comments/steps/step-02-post.md +97 -0
  61. package/src/prr/workflows/6-report/post-comments/workflow.md +45 -0
  62. package/src/prr/workflows/quick/workflow.md +244 -0
  63. package/tools/cli/commands/install.js +66 -0
  64. package/tools/cli/commands/status.js +36 -0
  65. package/tools/cli/commands/uninstall.js +38 -0
  66. package/tools/cli/installers/lib/core/config-collector.js +47 -0
  67. package/tools/cli/installers/lib/core/detector.js +46 -0
  68. package/tools/cli/installers/lib/core/installer.js +162 -0
  69. package/tools/cli/installers/lib/core/manifest-generator.js +172 -0
  70. package/tools/cli/installers/lib/core/manifest.js +62 -0
  71. package/tools/cli/installers/lib/ide/_base-ide.js +36 -0
  72. package/tools/cli/installers/lib/ide/_config-driven.js +167 -0
  73. package/tools/cli/installers/lib/ide/manager.js +97 -0
  74. package/tools/cli/installers/lib/ide/platform-codes.yaml +76 -0
  75. package/tools/cli/installers/lib/ide/shared/path-utils.js +11 -0
  76. package/tools/cli/installers/lib/ide/templates/combined/default-agent.md +16 -0
  77. package/tools/cli/installers/lib/ide/templates/combined/default-workflow.md +7 -0
  78. package/tools/cli/installers/lib/ide/templates/combined/windsurf-workflow.md +5 -0
  79. package/tools/cli/lib/agent/compiler.js +123 -0
  80. package/tools/cli/lib/agent/template-engine.js +73 -0
  81. package/tools/cli/lib/cli-utils.js +32 -0
  82. package/tools/cli/lib/prompts.js +15 -0
  83. package/tools/cli/lib/ui.js +132 -0
  84. package/tools/cli/lib/xml-utils.js +24 -0
  85. package/tools/cli/prr-cli.js +36 -0
  86. package/tools/prr-npx-wrapper.js +6 -0
@@ -0,0 +1,131 @@
1
+ ---
2
+ name: "step-02-extract-rules"
3
+ description: "Extract and summarize actionable coding rules from the scanned files"
4
+ nextStepFile: "./step-03-ask-context.md"
5
+ ---
6
+
7
+ # Step 2: Extract Coding Rules
8
+
9
+ ## Sequence of Instructions
10
+
11
+ ### 1. Extract ESLint Rules (if found)
12
+
13
+ From the ESLint config, extract rules that are set to `"error"` or `2` (hard rules) and `"warn"` or `1` (soft rules).
14
+
15
+ Focus on rules with reviewer relevance:
16
+ - `no-unused-vars`, `no-console`, `no-debugger` → code quality
17
+ - `eqeqeq`, `no-implicit-coercion` → logic correctness
18
+ - `import/order`, `import/no-cycle` → architecture
19
+ - Any custom plugin rules (e.g. `vue/`, `react/`, `@typescript-eslint/`)
20
+ - `security/` plugin rules if present
21
+
22
+ Build a concise rule summary:
23
+ ```
24
+ ESLint hard rules: no-unused-vars, eqeqeq, @typescript-eslint/no-explicit-any
25
+ ESLint soft rules: no-console, prefer-const
26
+ Vue-specific: vue/no-unused-components, vue/component-name-in-template-casing
27
+ ```
28
+
29
+ ### 2. Extract TypeScript Strictness (if found)
30
+
31
+ From `tsconfig.json`, note:
32
+ - `strict: true/false`
33
+ - `noImplicitAny`, `strictNullChecks`, `noUnusedLocals`
34
+ - `paths` aliases (e.g. `@/` → `src/`) — important for import review
35
+
36
+ ### 3. Extract Naming Conventions
37
+
38
+ From all scanned files, build a naming conventions map:
39
+
40
+ | Thing | Convention | Example | Source |
41
+ |-------|-----------|---------|--------|
42
+ | Vue components | PascalCase | `UserCard.vue` | CONTRIBUTING.md |
43
+ | Composables | camelCase + `use` prefix | `useAuth.js` | CONTRIBUTING.md |
44
+ | Constants | UPPER_SNAKE_CASE | `MAX_RETRIES` | eslint rule |
45
+ | API endpoints | kebab-case | `/api/user-profile` | ARCHITECTURE.md |
46
+ | DB tables | snake_case | `user_sessions` | schema files |
47
+ | Test files | `*.spec.ts` or `*.test.ts` | `auth.spec.ts` | vitest config |
48
+
49
+ If a convention is NOT documented, infer from existing files:
50
+ ```bash
51
+ # Check actual naming in the repo (sample 10 files per type)
52
+ ls {target_repo}/src/components/*.vue 2>/dev/null | head -10
53
+ ls {target_repo}/src/composables/*.{js,ts} 2>/dev/null | head -10
54
+ ls {target_repo}/src/services/*.{js,ts} 2>/dev/null | head -10
55
+ ```
56
+
57
+ Note inferred conventions separately from documented ones.
58
+
59
+ ### 4. Extract Architecture Patterns
60
+
61
+ From architecture docs and code structure, identify:
62
+
63
+ **Layer structure** (which layer calls which):
64
+ ```
65
+ e.g.: routes → controllers → services → repositories → DB
66
+ e.g.: pages → composables → stores → API client → backend
67
+ ```
68
+
69
+ **Prohibited cross-layer calls** (if documented):
70
+ - "Services must not import from controllers"
71
+ - "Components must not call API directly — use stores"
72
+ - "Business logic must not live in route handlers"
73
+
74
+ **Established patterns to follow:**
75
+ - Error handling pattern (try/catch in service? global handler? Result type?)
76
+ - API response format (does the project have a standard `{ data, error, meta }` wrapper?)
77
+ - Auth check pattern (middleware? decorator? manual in each handler?)
78
+ - Logging pattern (which logger, log levels, structured vs string)
79
+
80
+ **Scan for pattern evidence:**
81
+ ```bash
82
+ # Check how existing API endpoints handle errors
83
+ grep -r "catch" {target_repo}/src --include="*.{js,ts}" -l | head -5
84
+ # Check existing service layer pattern
85
+ ls {target_repo}/src/services/ 2>/dev/null | head -10
86
+ ```
87
+
88
+ ### 5. Extract Test Conventions
89
+
90
+ From test config and existing test files:
91
+ - Test file location pattern (`__tests__/` vs `*.spec.ts` co-located vs `test/`)
92
+ - What is expected to be tested (unit? integration? e2e?)
93
+ - Test utilities used (custom render wrappers, fixture factories, etc.)
94
+ - Coverage threshold if configured
95
+
96
+ ### 6. Compile Extracted Rules Summary
97
+
98
+ Build a structured in-memory summary to pass to step-03:
99
+
100
+ ```yaml
101
+ linting:
102
+ hard_errors:
103
+ - "no-unused-vars"
104
+ - "eqeqeq"
105
+ soft_warnings:
106
+ - "no-console"
107
+ typescript_strict: true
108
+
109
+ naming:
110
+ documented:
111
+ - { thing: "Vue components", convention: "PascalCase", example: "UserCard.vue" }
112
+ inferred:
113
+ - { thing: "service files", convention: "camelCase", example: "authService.js" }
114
+
115
+ architecture:
116
+ layer_order: "routes → services → repositories"
117
+ prohibited:
118
+ - "No business logic in route handlers"
119
+ patterns:
120
+ error_handling: "try/catch in services, global error middleware in app.js"
121
+ api_format: "{ data, error } wrapper"
122
+
123
+ testing:
124
+ framework: "vitest"
125
+ file_pattern: "*.spec.ts"
126
+ location: "co-located with source files"
127
+ ```
128
+
129
+ ### 7. Load Next Step
130
+
131
+ Add `step-02-extract-rules` to `stepsCompleted`. Load: `{nextStepFile}`
@@ -0,0 +1,194 @@
1
+ ---
2
+ name: "step-03-ask-context"
3
+ description: "Ask user for domain knowledge and architectural context that cannot be inferred from files"
4
+ nextStepFile: "./step-04-save-context.md"
5
+ ---
6
+
7
+ # Step 3: Ask for Domain & Architecture Context
8
+
9
+ ## Sequence of Instructions
10
+
11
+ ### 1. Present Scan Summary
12
+
13
+ Show what was auto-discovered and what is still unknown:
14
+
15
+ ```
16
+ 📋 Auto-discovered context:
17
+ ✅ Stack: {detected_stack}
18
+ ✅ Linting: {n} hard rules, {n} soft rules
19
+ ✅ Naming conventions: {n} documented, {n} inferred
20
+ ✅ Architecture layers: {layer_order or "not documented"}
21
+ ✅ Test framework: {framework or "not found"}
22
+
23
+ ❓ Still need from you ({n} questions):
24
+ ```
25
+
26
+ ### 2. Ask Domain Questions
27
+
28
+ Ask these questions **one group at a time**. Wait for answer before continuing.
29
+
30
+ ---
31
+
32
+ **Group A: Business Domain**
33
+
34
+ ```
35
+ What does this project do? (1-3 sentences about the business domain)
36
+
37
+ Examples:
38
+ "E-commerce platform for B2B wholesale orders"
39
+ "Internal HR system for leave requests and payroll"
40
+ "SaaS analytics dashboard for marketing teams"
41
+
42
+ Your answer:
43
+ ```
44
+
45
+ Halt and wait for answer.
46
+
47
+ Then ask:
48
+
49
+ ```
50
+ What are the key domain entities? (the main "things" the system manages)
51
+
52
+ Examples: User, Order, Product, Invoice, Report, Campaign, Shift, etc.
53
+
54
+ Your answer (comma-separated):
55
+ ```
56
+
57
+ Halt and wait.
58
+
59
+ Then ask:
60
+
61
+ ```
62
+ Are there any domain-specific rules that code must enforce?
63
+ (business rules reviewers should verify, not just code quality)
64
+
65
+ Examples:
66
+ "An Order cannot transition from SHIPPED back to PENDING"
67
+ "A User must have at least one Role"
68
+ "Discount cannot exceed 50% without manager approval flag"
69
+ "All monetary values must be stored as integers (cents), never floats"
70
+
71
+ Your answer (or press Enter to skip):
72
+ ```
73
+
74
+ Halt and wait.
75
+
76
+ ---
77
+
78
+ **Group B: Review Priorities**
79
+
80
+ ```
81
+ What should reviewers focus on MOST for this project?
82
+ (select all that apply, or describe your priorities)
83
+
84
+ 1. Security — auth, injection, data exposure
85
+ 2. Performance — this is a high-traffic system
86
+ 3. Data integrity — DB transactions, consistency
87
+ 4. Test coverage — we require tests for all new code
88
+ 5. API contracts — breaking changes are critical
89
+ 6. Accessibility — frontend a11y matters
90
+ 7. Error handling — we need detailed error context
91
+
92
+ Your answer (numbers or description):
93
+ ```
94
+
95
+ Halt and wait.
96
+
97
+ Then ask:
98
+
99
+ ```
100
+ What should reviewers IGNORE or deprioritize?
101
+ (things that are intentional, handled elsewhere, or not worth flagging)
102
+
103
+ Examples:
104
+ "console.log is allowed in development, we strip in CI"
105
+ "We intentionally use callbacks in legacy modules, don't flag them"
106
+ "Test files don't need JSDoc"
107
+ "We allow 'any' in migration scripts"
108
+
109
+ Your answer (or press Enter to skip):
110
+ ```
111
+
112
+ Halt and wait.
113
+
114
+ ---
115
+
116
+ **Group C: Architecture Context** (only ask if architecture docs were NOT found in step-01)
117
+
118
+ ```
119
+ How is the codebase organized? What are the main layers/modules?
120
+
121
+ Examples:
122
+ "Vue 3 frontend (src/), Node/Express API (api/), shared types (shared/)"
123
+ "Monorepo: apps/web, apps/api, packages/ui, packages/utils"
124
+ "MVC: routes/, controllers/, services/, models/"
125
+ "Feature-based: src/features/{feature}/{components,hooks,api}/"
126
+
127
+ Your answer:
128
+ ```
129
+
130
+ Halt and wait.
131
+
132
+ Then ask:
133
+
134
+ ```
135
+ Are there any known anti-patterns or tech debt areas reviewers should know about?
136
+ (so they don't waste time flagging known issues)
137
+
138
+ Examples:
139
+ "auth module is legacy, will be rewritten — don't review deeply"
140
+ "UserController is a God class — we know, it's being split"
141
+ "Some old files still use callbacks — that's expected"
142
+
143
+ Your answer (or press Enter to skip):
144
+ ```
145
+
146
+ Halt and wait.
147
+
148
+ ---
149
+
150
+ **Group D: PR-specific guidelines**
151
+
152
+ ```
153
+ Any specific rules for what needs review before merging?
154
+
155
+ Examples:
156
+ "All PRs touching /api/payments must have security review"
157
+ "DB migration files require architecture review"
158
+ "Changes to auth/* always need two approvals"
159
+ "Frontend PRs need accessibility check"
160
+
161
+ Your answer (or press Enter to skip):
162
+ ```
163
+
164
+ Halt and wait.
165
+
166
+ ### 3. Confirm Collected Context
167
+
168
+ Display a summary of all answers received:
169
+
170
+ ```
171
+ ✅ Context collected:
172
+
173
+ Domain: {domain_description}
174
+ Key entities: {entities}
175
+ Business rules: {rules or "none specified"}
176
+
177
+ Review priorities: {priorities}
178
+ Ignore list: {ignore_list or "none"}
179
+
180
+ Architecture: {architecture_description}
181
+ Known debt: {debt_notes or "none"}
182
+ PR-specific rules: {pr_rules or "none"}
183
+
184
+ Is this correct? [Y] Save [E] Edit [S] Skip remaining
185
+ ```
186
+
187
+ Halt and wait for confirmation.
188
+
189
+ If `[E]` → ask which group to re-answer, then re-ask that group.
190
+ If `[S]` → proceed with what's collected so far.
191
+
192
+ ### 4. Load Next Step
193
+
194
+ Add `step-03-ask-context` to `stepsCompleted`. Load: `{nextStepFile}`
@@ -0,0 +1,161 @@
1
+ ---
2
+ name: "step-04-save-context"
3
+ description: "Save complete project context to YAML file for use by all review workflows"
4
+ ---
5
+
6
+ # Step 4: Save Project Context
7
+
8
+ ## Sequence of Instructions
9
+
10
+ ### 1. Assemble Complete Context Document
11
+
12
+ Combine everything from steps 01-03 into a single structured YAML:
13
+
14
+ ```yaml
15
+ # PR Review — Project Context
16
+ # Generated: {date}
17
+ # Project: {project_name}
18
+ # Repo: {target_repo}
19
+
20
+ meta:
21
+ generated_date: "{date}"
22
+ generated_by: "{user_name}"
23
+ project_name: "{project_name}"
24
+ schema_version: "1"
25
+
26
+ stack:
27
+ frontend: "{detected_frontend}" # vue3 / react / angular / none
28
+ backend: "{detected_backend}" # express / nestjs / django / none
29
+ language: "{primary_language}" # typescript / javascript / python / java
30
+ orm: "{orm_or_none}"
31
+ test_runner: "{test_framework}"
32
+ state_management: "{state_lib_or_none}"
33
+ build_tool: "{vite_or_webpack_etc}"
34
+
35
+ coding_standards:
36
+ enforced_rules: # from ESLint/linting configs
37
+ - "{rule_name}: {description}"
38
+ soft_warnings:
39
+ - "{rule_name}: {description}"
40
+ typescript:
41
+ strict: {true|false}
42
+ no_implicit_any: {true|false}
43
+ strict_null_checks: {true|false}
44
+
45
+ naming_conventions:
46
+ documented:
47
+ - thing: "{what}"
48
+ convention: "{PascalCase|camelCase|snake_case|kebab-case|UPPER_SNAKE}"
49
+ example: "{example}"
50
+ inferred:
51
+ - thing: "{what}"
52
+ convention: "{convention}"
53
+ example: "{example}"
54
+ note: "inferred from existing files, not documented"
55
+
56
+ architecture:
57
+ description: "{architecture_description}"
58
+ layer_order: "{layer → layer → layer}"
59
+ prohibited:
60
+ - "{cross-layer violation that must not happen}"
61
+ established_patterns:
62
+ error_handling: "{description}"
63
+ api_response_format: "{description or null}"
64
+ auth_pattern: "{description or null}"
65
+ logging: "{description or null}"
66
+ known_debt:
67
+ - "{known issue to deprioritize in reviews}"
68
+
69
+ testing:
70
+ framework: "{vitest|jest|pytest|none}"
71
+ file_pattern: "{*.spec.ts|*.test.ts|test_*.py}"
72
+ location: "{co-located|__tests__|test/ folder}"
73
+ coverage_threshold: "{percentage or null}"
74
+ what_requires_tests: "{all new code|only services|only utils|none documented}"
75
+
76
+ domain:
77
+ description: "{business domain description}"
78
+ key_entities:
79
+ - "{Entity}"
80
+ business_rules:
81
+ - "{rule that code must enforce}"
82
+ terminology:
83
+ - term: "{domain term}"
84
+ meaning: "{what it means in this project}"
85
+
86
+ review_guidelines:
87
+ priorities:
88
+ - "{what to focus on most}"
89
+ ignore_list:
90
+ - "{what to NOT flag — intentional or known}"
91
+ pr_specific_rules:
92
+ - "{when to require which review type}"
93
+ ```
94
+
95
+ ### 2. Write to File
96
+
97
+ Write the assembled YAML to:
98
+ ```
99
+ {review_output}/project-context.yaml
100
+ ```
101
+
102
+ ### 3. Write Human-Readable Summary
103
+
104
+ Also write a compact summary at:
105
+ ```
106
+ {review_output}/project-context-summary.md
107
+ ```
108
+
109
+ Content:
110
+ ```markdown
111
+ # Project Context: {project_name}
112
+
113
+ **Stack:** {frontend} + {backend} ({language})
114
+ **Generated:** {date} by {user_name}
115
+
116
+ ## Key Rules for Reviewers
117
+
118
+ ### Must Follow (enforced by linting)
119
+ {enforced_rules as bullet list}
120
+
121
+ ### Architecture Rules
122
+ - Layer order: {layer_order}
123
+ {prohibited as bullet list}
124
+
125
+ ### Naming Conventions
126
+ {naming table}
127
+
128
+ ### Business Rules
129
+ {business_rules as bullet list}
130
+
131
+ ### Review Priorities
132
+ {priorities as bullet list}
133
+
134
+ ### Do NOT Flag
135
+ {ignore_list as bullet list}
136
+ ```
137
+
138
+ ### 4. Display Completion
139
+
140
+ ```
141
+ ✅ Project Context Saved!
142
+ ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
143
+ 📄 Context file: {review_output}/project-context.yaml
144
+ 📋 Summary: {review_output}/project-context-summary.md
145
+
146
+ What was captured:
147
+ 🏗️ Stack: {stack_summary}
148
+ 📏 Linting rules: {n} hard, {n} soft
149
+ 🔤 Naming conventions: {n} documented, {n} inferred
150
+ 🏢 Architecture layers: {layer_order}
151
+ 📖 Business rules: {n}
152
+ 🎯 Review priorities: {n}
153
+ 🚫 Ignore list: {n} items
154
+
155
+ All review workflows will now load this context automatically.
156
+ ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
157
+
158
+ Next step: Run [SP] Select PR to begin reviewing.
159
+ ```
160
+
161
+ **Workflow complete.** Return to agent menu.
@@ -0,0 +1,58 @@
1
+ ---
2
+ name: collect-project-context
3
+ description: "Collect project coding standards, conventions, architecture rules, and business context — stored once and used by all review workflows"
4
+ main_config: "{project-root}/_prr/prr/config.yaml"
5
+ nextStep: "./steps/step-01-scan-configs.md"
6
+ output_file: "{review_output}/project-context.yaml"
7
+ ---
8
+
9
+ # Collect Project Context Workflow
10
+
11
+ **Goal:** Build a reusable knowledge base about THIS project — its coding standards, architecture patterns, business domain, and team conventions. All review workflows load this context so findings are accurate and relevant to the project, not just generic best practices.
12
+
13
+ ## WHY THIS MATTERS
14
+
15
+ Without project context, AI reviewers will:
16
+ - Flag code that intentionally follows project conventions
17
+ - Miss violations of domain-specific rules
18
+ - Suggest patterns that contradict what the team has established
19
+ - Not understand business logic to assess correctness
20
+
21
+ With project context, reviewers know:
22
+ - What rules are enforced (ESLint, Prettier, custom linting)
23
+ - What architecture patterns the team follows
24
+ - What the business domain is and key domain terms
25
+ - What to prioritize vs ignore for this specific codebase
26
+
27
+ ## WHEN TO RUN
28
+
29
+ - **First time** before any review in a new project
30
+ - **Re-run** when project conventions change significantly
31
+ - Output is saved to `{review_output}/project-context.yaml` and reused across all PRs
32
+
33
+ ## WORKFLOW ARCHITECTURE
34
+
35
+ 4-step process:
36
+ 1. Scan repo for config files and standards documents
37
+ 2. Extract coding rules from linting/formatting configs
38
+ 3. Ask user for domain and architecture context
39
+ 4. Save complete project context to YAML file
40
+
41
+ ## INITIALIZATION
42
+
43
+ Load config from `{main_config}`.
44
+ Check if `{review_output}/project-context.yaml` already exists.
45
+
46
+ If it exists, ask:
47
+ ```
48
+ 📋 Project context already exists (created: {existing_date}).
49
+ [U] Update — re-scan and update context
50
+ [K] Keep — use existing context, skip this workflow
51
+ [R] Replace — start fresh
52
+ ```
53
+
54
+ Halt and wait for user choice before proceeding.
55
+
56
+ ## EXECUTION
57
+
58
+ Read fully and follow: `{nextStep}`
@@ -0,0 +1,68 @@
1
+ ---
2
+ name: "step-01-fetch"
3
+ description: "Detect platform and run git fetch to ensure latest remote state"
4
+ nextStepFile: "./step-02-list-branches.md"
5
+ ---
6
+
7
+ # Step 1: Detect Platform and Fetch Latest
8
+
9
+ **Progress: Step 1 of 5** — Detecting platform and ensuring up-to-date remote state
10
+
11
+ ## MANDATORY EXECUTION RULES
12
+
13
+ - 🛑 ALWAYS fetch before listing — stale branch info leads to wrong reviews
14
+ - 📖 Read this entire file before taking any action
15
+ - ✅ Communicate in `{communication_language}`
16
+
17
+ ## Sequence of Instructions
18
+
19
+ ### 1. Detect Platform
20
+
21
+ If `{platform}` is `auto` or empty, detect from the git remote URL:
22
+
23
+ ```bash
24
+ git -C {target_repo} remote get-url origin
25
+ ```
26
+
27
+ Map remote URL to platform:
28
+
29
+ | Remote URL pattern | Platform |
30
+ |-------------------|----------|
31
+ | `github.com` | `github` |
32
+ | `gitlab.com` or self-hosted GitLab | `gitlab` |
33
+ | `dev.azure.com` or `visualstudio.com` | `azure` |
34
+ | `bitbucket.org` | `bitbucket` |
35
+ | No remote / local only | `none` |
36
+
37
+ Set `{detected_platform}` = detected value.
38
+
39
+ Also extract `{detected_platform_repo}` from the URL if `{platform_repo}` is empty:
40
+ - GitHub/GitLab/Bitbucket: extract `owner/repo` (strip `.git` suffix)
41
+ - Azure DevOps: extract `org/project/repo` from `dev.azure.com/{org}/{project}/_git/{repo}`
42
+
43
+ Display:
44
+ ```
45
+ 🔍 Platform detected: {detected_platform}
46
+ Remote: {platform_repo or detected_platform_repo}
47
+ ```
48
+
49
+ If platform cannot be detected, set `{detected_platform}` = `none` and continue.
50
+
51
+ ### 2. Fetch Latest from Remote
52
+
53
+ ```bash
54
+ git -C {target_repo} fetch origin --prune
55
+ ```
56
+
57
+ **If fetch succeeds:** Show `✓ Fetched latest from remote` and proceed.
58
+
59
+ **If fetch fails:**
60
+ - Show the error message
61
+ - Ask user: Retry / Continue with local state / Cancel
62
+ - Wait for response before proceeding
63
+
64
+ ### 3. Update Frontmatter and Load Next Step
65
+
66
+ Add `step-01-fetch` to `stepsCompleted`. Store `detected_platform` and `detected_platform_repo` for use in subsequent steps.
67
+
68
+ Read fully and follow: `{nextStepFile}`
@@ -0,0 +1,95 @@
1
+ ---
2
+ name: "step-02-list-prs"
3
+ description: "List open PRs/MRs via platform CLI (primary) and recent branches (secondary)"
4
+ nextStepFile: "./step-03-select.md"
5
+ ---
6
+
7
+ # Step 2: List Open PRs and Branches
8
+
9
+ **Progress: Step 2 of 5** — Listing available PRs/MRs and branches
10
+
11
+ ## STEP GOAL
12
+
13
+ Show open PRs/MRs from the configured platform as the **primary** selection list.
14
+ Always show recent branches as secondary. Fall back to branch-only if no platform configured.
15
+
16
+ Use `{platform}` (or `{detected_platform}` from step 1 if platform = auto).
17
+
18
+ ## Sequence of Instructions
19
+
20
+ ### 1. List Open PRs/MRs (Primary)
21
+
22
+ Run the appropriate command based on platform:
23
+
24
+ **GitHub** (`platform = github`, requires `gh` CLI):
25
+ ```bash
26
+ gh pr list --repo {platform_repo} --state open \
27
+ --json number,title,headRefName,baseRefName,author,createdAt,isDraft \
28
+ --limit 20
29
+ ```
30
+
31
+ **GitLab** (`platform = gitlab`, requires `glab` CLI):
32
+ ```bash
33
+ glab mr list --repo {platform_repo} --state opened \
34
+ --output json
35
+ ```
36
+ Fields to use: `iid` (MR number), `title`, `source_branch`, `target_branch`, `author.username`, `created_at`, `draft`.
37
+
38
+ **Azure DevOps** (`platform = azure`, requires `az` CLI with `azure-devops` extension):
39
+ ```bash
40
+ az repos pr list --repository {repo} --project {project} --org {org_url} \
41
+ --status active --output json
42
+ ```
43
+ Where `{platform_repo}` format is `org/project/repo` → extract accordingly.
44
+ Fields: `pullRequestId`, `title`, `sourceRefName`, `targetRefName`, `createdBy.displayName`, `creationDate`.
45
+
46
+ **Bitbucket** (`platform = bitbucket`, requires `bb` CLI or `curl`):
47
+ ```bash
48
+ bb prs list --repo {platform_repo} --state OPEN
49
+ ```
50
+ Or via API: `curl https://api.bitbucket.org/2.0/repositories/{platform_repo}/pullrequests?state=OPEN`
51
+ Fields: `id`, `title`, `source.branch.name`, `destination.branch.name`, `author.display_name`.
52
+
53
+ **None / local** (`platform = none` or no platform configured): skip to step 2.
54
+
55
+ If the command **succeeds and returns PRs/MRs**, display them as the main list:
56
+
57
+ ```
58
+ 🔗 Open PRs on {platform_repo}: ({platform})
59
+ ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
60
+ #45 [DRAFT] "Add OAuth2 login" feature/oauth → main @alice 3h ago
61
+ #44 "Fix memory leak in dashboard" fix/memory-leak → main @bob 1d ago
62
+ #43 "Refactor API layer" refactor/api → develop @carol 2d ago
63
+ ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
64
+ ```
65
+
66
+ Set `pr_list_available = true`. Store the PR/MR list for step 3.
67
+
68
+ If the command **fails or returns empty**, set `pr_list_available = false`.
69
+
70
+ ### 2. List Recent Branches (Always shown as secondary / fallback)
71
+
72
+ ```bash
73
+ git -C {target_repo} branch -r --sort=-committerdate \
74
+ --format="%(refname:short) | %(objectname:short) | %(committerdate:relative) | %(contents:subject)" \
75
+ | head -15
76
+ ```
77
+
78
+ Display as secondary reference (or primary if `pr_list_available = false`):
79
+ ```
80
+ 🌿 Recent branches (newest first):
81
+ 1. origin/feature/oauth (abc1234) — 3 hours ago — "Add OAuth2 login"
82
+ 2. origin/fix/memory-leak (def5678) — 1 day ago — "Fix memory leak"
83
+ ...
84
+ ```
85
+
86
+ If `pr_list_available = false`, add note:
87
+ ```
88
+ ⚠️ Platform PR list unavailable — select by branch name instead.
89
+ ```
90
+
91
+ ### 3. Update Frontmatter and Load Next Step
92
+
93
+ Add `step-02-list-prs` to `stepsCompleted`.
94
+
95
+ Read fully and follow: `{nextStepFile}`