ira-review 0.2.0 → 0.3.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/README.github.md +227 -56
- package/README.md +68 -25
- package/README.npm.md +68 -25
- package/dist/cli.js +366 -73
- package/dist/index.cjs +342 -52
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +50 -12
- package/dist/index.d.ts +50 -12
- package/dist/index.js +340 -52
- package/dist/index.js.map +1 -1
- package/package.json +1 -1
package/README.github.md
CHANGED
|
@@ -1,14 +1,16 @@
|
|
|
1
1
|
# ira-review
|
|
2
2
|
|
|
3
|
-
**AI-powered PR reviews with built-in JIRA intelligence.**
|
|
3
|
+
**AI-powered PR reviews with optional SonarQube integration and built-in JIRA intelligence.**
|
|
4
4
|
|
|
5
|
-
We've all been there.
|
|
5
|
+
We've all been there. Someone opens a PR, and now the team has to comb through it for bugs, security issues, complexity hotspots, and whether it actually meets the acceptance criteria. It's tedious and eats up review time.
|
|
6
6
|
|
|
7
|
-
IRA takes that off your plate.
|
|
7
|
+
IRA takes that off your plate. Point it at a pull request and it runs an AI-powered review — posting clear comments with explanations, impact assessments, and suggested fixes. If you have SonarQube or SonarCloud, IRA can pull in those issues too and enrich them with AI analysis. But Sonar isn't required. IRA works just fine in **standalone mode**, reviewing your PRs with AI alone.
|
|
8
|
+
|
|
9
|
+
On top of that, it scores the overall risk of your PR, flags complex code, checks your JIRA acceptance criteria, deduplicates comments across re-runs, and can send review summaries to Slack or Microsoft Teams.
|
|
8
10
|
|
|
9
11
|
## Language and framework support
|
|
10
12
|
|
|
11
|
-
IRA works with **any language
|
|
13
|
+
IRA works with **any language**. In standalone mode, it reviews your PR using AI directly. When SonarQube is configured, it picks up the issues that Sonar already found and sends them to AI for explanation and fixes — so if Sonar can analyze your code, IRA can review it.
|
|
12
14
|
|
|
13
15
|
IRA itself is an npm package and needs Node.js to run, but your project doesn't have to be a JavaScript project. You just run IRA as a CLI tool in your pipeline, the same way you'd use any other linting or code quality tool.
|
|
14
16
|
|
|
@@ -40,7 +42,7 @@ You don't need to touch your `pom.xml` or `build.gradle`. Just add a step in you
|
|
|
40
42
|
- uses: actions/setup-node@v4
|
|
41
43
|
with:
|
|
42
44
|
node-version: 20
|
|
43
|
-
- run: npx ira-review review --pr ${{ github.event.pull_request.number }} --dry-run
|
|
45
|
+
- run: npx ira-review review --pr ${{ github.event.pull_request.number }} --scm-provider github --dry-run
|
|
44
46
|
```
|
|
45
47
|
|
|
46
48
|
### Python projects
|
|
@@ -52,7 +54,7 @@ Same idea. Just run IRA as a one-off command in your pipeline.
|
|
|
52
54
|
- uses: actions/setup-node@v4
|
|
53
55
|
with:
|
|
54
56
|
node-version: 20
|
|
55
|
-
- run: npx ira-review review --pr ${{ github.event.pull_request.number }} --dry-run
|
|
57
|
+
- run: npx ira-review review --pr ${{ github.event.pull_request.number }} --scm-provider github --dry-run
|
|
56
58
|
```
|
|
57
59
|
|
|
58
60
|
You can also add it to a Makefile if that's how your team works:
|
|
@@ -68,13 +70,12 @@ It all works the same way. If Node.js is available in your CI environment (and i
|
|
|
68
70
|
|
|
69
71
|
```bash
|
|
70
72
|
npx ira-review review \
|
|
71
|
-
--sonar-url https://sonarcloud.io \
|
|
72
|
-
--sonar-token $SONAR_TOKEN \
|
|
73
|
-
--project-key my-project \
|
|
74
73
|
--pr $PR_ID \
|
|
75
74
|
--dry-run
|
|
76
75
|
```
|
|
77
76
|
|
|
77
|
+
Add `--sonar-url` and `--sonar-token` if you want SonarQube analysis included. Without them, IRA runs in standalone mode.
|
|
78
|
+
|
|
78
79
|
`npx` downloads and runs IRA on the fly, so there's nothing to install beforehand.
|
|
79
80
|
|
|
80
81
|
### No Node.js? Use Docker
|
|
@@ -83,15 +84,14 @@ If your CI environment doesn't have Node.js and you can't install it, you can ru
|
|
|
83
84
|
|
|
84
85
|
```bash
|
|
85
86
|
docker run --rm node:20-slim npx ira-review review \
|
|
86
|
-
--sonar-url https://sonarcloud.io \
|
|
87
|
-
--sonar-token $SONAR_TOKEN \
|
|
88
|
-
--project-key my-project \
|
|
89
87
|
--pr $PR_ID \
|
|
90
88
|
--dry-run
|
|
91
89
|
```
|
|
92
90
|
|
|
93
91
|
## How it works
|
|
94
92
|
|
|
93
|
+
### With SonarQube
|
|
94
|
+
|
|
95
95
|
```mermaid
|
|
96
96
|
flowchart LR
|
|
97
97
|
subgraph Your CI/CD Pipeline
|
|
@@ -99,13 +99,31 @@ flowchart LR
|
|
|
99
99
|
B --> C[IRA picks up issues]
|
|
100
100
|
end
|
|
101
101
|
subgraph IRA Review Engine
|
|
102
|
-
C --> D[Filters
|
|
102
|
+
C --> D[Filters by severity]
|
|
103
103
|
D --> E[Detects framework]
|
|
104
104
|
E --> F[AI generates reviews]
|
|
105
105
|
F --> G[Calculates risk score]
|
|
106
106
|
end
|
|
107
107
|
G --> H[Posts comments on PR]
|
|
108
108
|
G --> I[Validates JIRA AC]
|
|
109
|
+
G --> J[Sends notifications]
|
|
110
|
+
```
|
|
111
|
+
|
|
112
|
+
### Standalone mode (no Sonar)
|
|
113
|
+
|
|
114
|
+
```mermaid
|
|
115
|
+
flowchart LR
|
|
116
|
+
subgraph Your CI/CD Pipeline
|
|
117
|
+
A[Developer pushes code] --> C[IRA reviews PR]
|
|
118
|
+
end
|
|
119
|
+
subgraph IRA Review Engine
|
|
120
|
+
C --> E[Detects framework]
|
|
121
|
+
E --> F[AI generates reviews]
|
|
122
|
+
F --> G[Calculates risk score]
|
|
123
|
+
end
|
|
124
|
+
G --> H[Posts comments on PR]
|
|
125
|
+
G --> I[Validates JIRA AC]
|
|
126
|
+
G --> J[Sends notifications]
|
|
109
127
|
```
|
|
110
128
|
|
|
111
129
|
Here's the full flow in detail:
|
|
@@ -114,53 +132,92 @@ Here's the full flow in detail:
|
|
|
114
132
|
sequenceDiagram
|
|
115
133
|
participant Dev as Developer
|
|
116
134
|
participant CI as CI/CD Pipeline
|
|
117
|
-
participant Sonar as SonarQube
|
|
135
|
+
participant Sonar as SonarQube (optional)
|
|
118
136
|
participant IRA as IRA Review
|
|
119
137
|
participant AI as OpenAI
|
|
120
|
-
participant SCM as Bitbucket
|
|
138
|
+
participant SCM as Bitbucket / GitHub
|
|
121
139
|
participant JIRA as JIRA (optional)
|
|
140
|
+
participant Notify as Slack / Teams (optional)
|
|
122
141
|
|
|
123
142
|
Dev->>CI: Push code / Open PR
|
|
124
|
-
|
|
125
|
-
|
|
143
|
+
opt SonarQube configured
|
|
144
|
+
CI->>Sonar: Run static analysis
|
|
145
|
+
Sonar-->>CI: Analysis complete
|
|
146
|
+
end
|
|
126
147
|
CI->>IRA: Run ira-review
|
|
127
|
-
|
|
128
|
-
|
|
148
|
+
opt SonarQube configured
|
|
149
|
+
IRA->>Sonar: Fetch PR issues (API)
|
|
150
|
+
Sonar-->>IRA: Issues matching min severity
|
|
151
|
+
end
|
|
129
152
|
IRA->>AI: Send each issue for review
|
|
130
153
|
AI-->>IRA: Explanation + Impact + Fix
|
|
131
154
|
IRA->>IRA: Calculate risk score
|
|
132
|
-
IRA->>
|
|
133
|
-
JIRA
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
155
|
+
IRA->>IRA: Check for duplicate comments
|
|
156
|
+
opt JIRA configured
|
|
157
|
+
IRA->>JIRA: Fetch acceptance criteria
|
|
158
|
+
JIRA-->>IRA: AC from ticket
|
|
159
|
+
IRA->>AI: Validate AC against issues
|
|
160
|
+
AI-->>IRA: Pass/Fail per criterion
|
|
161
|
+
end
|
|
162
|
+
IRA->>SCM: Post inline comments (deduplicated)
|
|
163
|
+
IRA->>SCM: Post summary comment
|
|
164
|
+
opt Notifications configured
|
|
165
|
+
IRA->>Notify: Send review summary
|
|
166
|
+
end
|
|
138
167
|
```
|
|
139
168
|
|
|
140
169
|
## What it does
|
|
141
170
|
|
|
142
|
-
1.
|
|
143
|
-
2.
|
|
171
|
+
1. Reviews your pull request using AI — with or without SonarQube issues
|
|
172
|
+
2. When SonarQube is configured, pulls issues and filters by minimum severity (default: CRITICAL and above)
|
|
144
173
|
3. Detects your framework (React, Angular, Vue, NestJS, Node) to give smarter suggestions
|
|
145
174
|
4. Sends each issue to AI for a plain-English explanation and a concrete fix
|
|
146
175
|
5. Calculates a risk score for the PR based on issues, security concerns, and complexity
|
|
147
176
|
6. Analyzes code complexity and highlights the hotspots
|
|
148
177
|
7. Validates JIRA acceptance criteria against the PR (if you've set up JIRA)
|
|
149
|
-
8.
|
|
178
|
+
8. Deduplicates comments — re-runs skip issues that were already commented on
|
|
179
|
+
9. Posts a formatted summary comment with risk score, overview, and complexity hotspots
|
|
180
|
+
10. Posts inline comments back to your pull request on Bitbucket or GitHub
|
|
181
|
+
11. Sends review summaries to Slack and/or Microsoft Teams (if webhooks are configured)
|
|
150
182
|
|
|
151
183
|
## Install
|
|
152
184
|
|
|
185
|
+
**Run once with `npx` (no install needed):**
|
|
186
|
+
```bash
|
|
187
|
+
npx ira-review review --pr 42 --dry-run
|
|
188
|
+
```
|
|
189
|
+
|
|
190
|
+
**Install as a dev dependency (recommended for projects):**
|
|
191
|
+
```bash
|
|
192
|
+
npm install --save-dev ira-review
|
|
193
|
+
npx ira-review review --pr 42 --dry-run
|
|
194
|
+
```
|
|
195
|
+
|
|
196
|
+
**Install globally:**
|
|
153
197
|
```bash
|
|
154
|
-
npm install ira-review
|
|
198
|
+
npm install -g ira-review
|
|
199
|
+
ira-review review --pr 42 --dry-run
|
|
155
200
|
```
|
|
156
201
|
|
|
157
202
|
## Quick start
|
|
158
203
|
|
|
159
|
-
|
|
204
|
+
### Standalone mode (no SonarQube)
|
|
205
|
+
|
|
206
|
+
The fastest way to try it out. This runs a pure AI review and prints everything to your terminal.
|
|
160
207
|
|
|
161
208
|
```bash
|
|
162
209
|
export OPENAI_API_KEY=[REDACTED:api-key]
|
|
163
210
|
|
|
211
|
+
npx ira-review review \
|
|
212
|
+
--pr 42 \
|
|
213
|
+
--dry-run
|
|
214
|
+
```
|
|
215
|
+
|
|
216
|
+
### With SonarQube
|
|
217
|
+
|
|
218
|
+
If you have SonarQube or SonarCloud, add your Sonar config to get issue-level analysis:
|
|
219
|
+
|
|
220
|
+
```bash
|
|
164
221
|
npx ira-review review \
|
|
165
222
|
--sonar-url https://sonarcloud.io \
|
|
166
223
|
--sonar-token sqa_xxxxx \
|
|
@@ -169,18 +226,49 @@ npx ira-review review \
|
|
|
169
226
|
--dry-run
|
|
170
227
|
```
|
|
171
228
|
|
|
229
|
+
### Posting to Bitbucket
|
|
230
|
+
|
|
172
231
|
Once you're happy with how it works, drop the `--dry-run` flag and add your Bitbucket credentials to start posting comments on real PRs:
|
|
173
232
|
|
|
174
233
|
```bash
|
|
175
234
|
npx ira-review review \
|
|
176
|
-
--sonar-url https://sonarcloud.io \
|
|
177
|
-
--sonar-token sqa_xxxxx \
|
|
178
|
-
--project-key my-org_my-project \
|
|
179
235
|
--pr 42 \
|
|
180
236
|
--bitbucket-token bb_xxxxx \
|
|
181
237
|
--repo my-workspace/my-repo
|
|
182
238
|
```
|
|
183
239
|
|
|
240
|
+
### Posting to GitHub
|
|
241
|
+
|
|
242
|
+
Use `--scm-provider github` to post comments on GitHub PRs:
|
|
243
|
+
|
|
244
|
+
```bash
|
|
245
|
+
npx ira-review review \
|
|
246
|
+
--pr 42 \
|
|
247
|
+
--scm-provider github \
|
|
248
|
+
--github-token ghp_xxxxx \
|
|
249
|
+
--github-repo owner/repo
|
|
250
|
+
```
|
|
251
|
+
|
|
252
|
+
## Config file
|
|
253
|
+
|
|
254
|
+
Instead of passing flags every time, you can create a `.irarc.json` or `ira.config.json` in your project root:
|
|
255
|
+
|
|
256
|
+
```json
|
|
257
|
+
{
|
|
258
|
+
"sonarUrl": "https://sonarcloud.io",
|
|
259
|
+
"sonarToken": "sqa_xxxxx",
|
|
260
|
+
"projectKey": "my-org_my-project",
|
|
261
|
+
"scmProvider": "github",
|
|
262
|
+
"githubToken": "ghp_xxxxx",
|
|
263
|
+
"githubRepo": "owner/repo",
|
|
264
|
+
"minSeverity": "MAJOR",
|
|
265
|
+
"slackWebhook": "https://hooks.slack.com/services/xxx/yyy/zzz",
|
|
266
|
+
"dryRun": false
|
|
267
|
+
}
|
|
268
|
+
```
|
|
269
|
+
|
|
270
|
+
**Priority order:** CLI flags > config file > environment variables. So you can set your defaults in the config file and override them with flags when needed.
|
|
271
|
+
|
|
184
272
|
## PR risk scoring
|
|
185
273
|
|
|
186
274
|
Every review automatically calculates a risk score based on five factors:
|
|
@@ -210,7 +298,7 @@ In dry-run mode you'll see something like:
|
|
|
210
298
|
|
|
211
299
|
## Code complexity insights
|
|
212
300
|
|
|
213
|
-
IRA fetches complexity metrics from SonarQube's measures API and flags the files that need attention:
|
|
301
|
+
IRA fetches complexity metrics from SonarQube's measures API (when configured) and flags the files that need attention:
|
|
214
302
|
|
|
215
303
|
- **Cyclomatic complexity** tells you how many paths exist through the code
|
|
216
304
|
- **Cognitive complexity** tells you how hard it is to understand
|
|
@@ -218,15 +306,40 @@ IRA fetches complexity metrics from SonarQube's measures API and flags the files
|
|
|
218
306
|
|
|
219
307
|
Any file with complexity above 15 gets flagged as a hotspot. This feeds into the risk score and shows up in dry-run output.
|
|
220
308
|
|
|
309
|
+
## Summary comments
|
|
310
|
+
|
|
311
|
+
IRA posts a formatted summary comment on every PR with:
|
|
312
|
+
|
|
313
|
+
- **Risk score** — the overall risk level with a breakdown of contributing factors
|
|
314
|
+
- **Overview** — a high-level summary of what the review found
|
|
315
|
+
- **Complexity hotspots** — files with high cyclomatic or cognitive complexity
|
|
316
|
+
- **JIRA AC results** — pass/fail status for each acceptance criterion (if JIRA is configured)
|
|
317
|
+
|
|
318
|
+
This gives reviewers a quick at-a-glance view without scrolling through individual inline comments.
|
|
319
|
+
|
|
320
|
+
## Comment deduplication
|
|
321
|
+
|
|
322
|
+
When you re-run IRA on the same PR (e.g., after pushing a fix), it checks existing comments and skips issues that were already commented on. No more duplicate comments cluttering your PR. This works automatically — no configuration needed.
|
|
323
|
+
|
|
324
|
+
## Slack and Teams notifications
|
|
325
|
+
|
|
326
|
+
Send review summaries to your team's channels by providing webhook URLs:
|
|
327
|
+
|
|
328
|
+
```bash
|
|
329
|
+
npx ira-review review \
|
|
330
|
+
--pr 42 \
|
|
331
|
+
--slack-webhook https://hooks.slack.com/services/xxx/yyy/zzz \
|
|
332
|
+
--teams-webhook https://outlook.office.com/webhook/xxx
|
|
333
|
+
```
|
|
334
|
+
|
|
335
|
+
Both can be used at the same time. The notification includes the risk score, issue count, and a link back to the PR.
|
|
336
|
+
|
|
221
337
|
## JIRA acceptance criteria validation
|
|
222
338
|
|
|
223
339
|
If your team tracks acceptance criteria in JIRA, IRA can check whether a PR actually meets them. This is completely optional and only kicks in when you provide your JIRA config.
|
|
224
340
|
|
|
225
341
|
```bash
|
|
226
342
|
npx ira-review review \
|
|
227
|
-
--sonar-url https://sonarcloud.io \
|
|
228
|
-
--sonar-token sqa_xxxxx \
|
|
229
|
-
--project-key my-org_my-project \
|
|
230
343
|
--pr 42 \
|
|
231
344
|
--jira-url https://yourcompany.atlassian.net \
|
|
232
345
|
--jira-email dev@company.com \
|
|
@@ -235,7 +348,7 @@ npx ira-review review \
|
|
|
235
348
|
--dry-run
|
|
236
349
|
```
|
|
237
350
|
|
|
238
|
-
IRA fetches the JIRA ticket, pulls out the acceptance criteria, and uses AI to check each one against the
|
|
351
|
+
IRA fetches the JIRA ticket, pulls out the acceptance criteria, and uses AI to check each one against the review analysis. The output looks like:
|
|
239
352
|
|
|
240
353
|
```
|
|
241
354
|
✅ JIRA Acceptance: PROJ-123 - Add user authentication
|
|
@@ -261,21 +374,24 @@ If you want more control, you can use IRA programmatically instead of the CLI:
|
|
|
261
374
|
import { ReviewEngine } from "ira-review";
|
|
262
375
|
|
|
263
376
|
const engine = new ReviewEngine({
|
|
377
|
+
// SonarQube is optional — omit to run in standalone mode
|
|
264
378
|
sonar: {
|
|
265
379
|
baseUrl: "https://sonarcloud.io",
|
|
266
380
|
token: "sqa_xxxxx",
|
|
267
381
|
projectKey: "my-org_my-project",
|
|
268
382
|
},
|
|
383
|
+
scmProvider: "github", // "bitbucket" (default) or "github"
|
|
269
384
|
scm: {
|
|
270
|
-
token: "
|
|
271
|
-
|
|
272
|
-
|
|
385
|
+
token: "ghp_xxxxx",
|
|
386
|
+
owner: "my-org",
|
|
387
|
+
repo: "my-repo",
|
|
273
388
|
},
|
|
274
389
|
ai: {
|
|
275
390
|
provider: "openai",
|
|
276
391
|
apiKey: process.env.OPENAI_API_KEY!,
|
|
277
392
|
},
|
|
278
393
|
pullRequestId: "42",
|
|
394
|
+
minSeverity: "MAJOR",
|
|
279
395
|
// Optional JIRA integration
|
|
280
396
|
jira: {
|
|
281
397
|
baseUrl: "https://yourcompany.atlassian.net",
|
|
@@ -283,6 +399,11 @@ const engine = new ReviewEngine({
|
|
|
283
399
|
token: "jira_xxxxx",
|
|
284
400
|
},
|
|
285
401
|
jiraTicket: "PROJ-123",
|
|
402
|
+
// Optional notifications
|
|
403
|
+
notifications: {
|
|
404
|
+
slackWebhookUrl: "https://hooks.slack.com/services/xxx/yyy/zzz",
|
|
405
|
+
teamsWebhookUrl: "https://outlook.office.com/webhook/xxx",
|
|
406
|
+
},
|
|
286
407
|
});
|
|
287
408
|
|
|
288
409
|
const result = await engine.run();
|
|
@@ -296,27 +417,34 @@ If you just want to preview without posting anything, add `dryRun: true` to the
|
|
|
296
417
|
|
|
297
418
|
## Environment variables
|
|
298
419
|
|
|
299
|
-
If you're tired of passing flags every time, set these environment variables instead. CLI flags
|
|
420
|
+
If you're tired of passing flags every time, set these environment variables instead. CLI flags and config file values still take priority.
|
|
300
421
|
|
|
301
422
|
| Variable | What it does |
|
|
302
423
|
|---|---|
|
|
303
424
|
| `OPENAI_API_KEY` | Your OpenAI API key (required) |
|
|
304
|
-
| `IRA_SONAR_URL` | SonarQube/SonarCloud URL |
|
|
305
|
-
| `IRA_SONAR_TOKEN` | Sonar API token |
|
|
306
|
-
| `IRA_PROJECT_KEY` | Sonar project key |
|
|
425
|
+
| `IRA_SONAR_URL` | SonarQube/SonarCloud URL (optional) |
|
|
426
|
+
| `IRA_SONAR_TOKEN` | Sonar API token (optional) |
|
|
427
|
+
| `IRA_PROJECT_KEY` | Sonar project key (optional) |
|
|
307
428
|
| `IRA_PR` | Pull request ID |
|
|
429
|
+
| `IRA_SCM_PROVIDER` | `bitbucket` (default) or `github` |
|
|
308
430
|
| `IRA_BITBUCKET_TOKEN` | Bitbucket API token |
|
|
309
431
|
| `IRA_BITBUCKET_URL` | Bitbucket Server URL (only for self-hosted) |
|
|
310
432
|
| `IRA_REPO` | `workspace/repo-slug` format |
|
|
433
|
+
| `IRA_GITHUB_TOKEN` | GitHub API token |
|
|
434
|
+
| `IRA_GITHUB_REPO` | `owner/repo` format |
|
|
435
|
+
| `IRA_GITHUB_URL` | GitHub Enterprise URL (only for self-hosted) |
|
|
436
|
+
| `IRA_MIN_SEVERITY` | Minimum severity to include: `BLOCKER`, `CRITICAL`, `MAJOR`, `MINOR`, `INFO` (default: `CRITICAL`) |
|
|
437
|
+
| `IRA_SLACK_WEBHOOK` | Slack incoming webhook URL (optional) |
|
|
438
|
+
| `IRA_TEAMS_WEBHOOK` | Microsoft Teams webhook URL (optional) |
|
|
311
439
|
| `IRA_JIRA_URL` | JIRA base URL (optional) |
|
|
312
440
|
| `IRA_JIRA_EMAIL` | JIRA account email (optional) |
|
|
313
441
|
| `IRA_JIRA_TOKEN` | JIRA API token (optional) |
|
|
314
442
|
|
|
315
443
|
You can also copy `.env.example` to `.env` and fill in the values there.
|
|
316
444
|
|
|
317
|
-
## CI/CD
|
|
445
|
+
## CI/CD examples
|
|
318
446
|
|
|
319
|
-
|
|
447
|
+
### Bitbucket Pipelines
|
|
320
448
|
|
|
321
449
|
```yaml
|
|
322
450
|
pipelines:
|
|
@@ -334,6 +462,36 @@ pipelines:
|
|
|
334
462
|
IRA_BITBUCKET_TOKEN: $BB_TOKEN
|
|
335
463
|
```
|
|
336
464
|
|
|
465
|
+
### GitHub Actions
|
|
466
|
+
|
|
467
|
+
```yaml
|
|
468
|
+
name: AI Code Review
|
|
469
|
+
on:
|
|
470
|
+
pull_request:
|
|
471
|
+
types: [opened, synchronize]
|
|
472
|
+
|
|
473
|
+
jobs:
|
|
474
|
+
review:
|
|
475
|
+
runs-on: ubuntu-latest
|
|
476
|
+
steps:
|
|
477
|
+
- uses: actions/setup-node@v4
|
|
478
|
+
with:
|
|
479
|
+
node-version: 20
|
|
480
|
+
- run: |
|
|
481
|
+
npx ira-review review \
|
|
482
|
+
--pr ${{ github.event.pull_request.number }} \
|
|
483
|
+
--scm-provider github \
|
|
484
|
+
--github-token ${{ secrets.GITHUB_TOKEN }} \
|
|
485
|
+
--github-repo ${{ github.repository }}
|
|
486
|
+
env:
|
|
487
|
+
OPENAI_API_KEY: ${{ secrets.OPENAI_API_KEY }}
|
|
488
|
+
IRA_SONAR_URL: ${{ secrets.SONAR_URL }}
|
|
489
|
+
IRA_SONAR_TOKEN: ${{ secrets.SONAR_TOKEN }}
|
|
490
|
+
IRA_PROJECT_KEY: ${{ secrets.SONAR_PROJECT_KEY }}
|
|
491
|
+
```
|
|
492
|
+
|
|
493
|
+
Remove the `IRA_SONAR_*` variables to run in standalone mode without SonarQube.
|
|
494
|
+
|
|
337
495
|
All tokens come from your pipeline's secret variables. IRA never stores or transmits them anywhere else.
|
|
338
496
|
|
|
339
497
|
## What the comments look like
|
|
@@ -361,15 +519,22 @@ variable is needed later, move the declaration to where it's first used.
|
|
|
361
519
|
ira-review review [options]
|
|
362
520
|
|
|
363
521
|
Options:
|
|
364
|
-
--sonar-url <url> SonarQube base URL
|
|
522
|
+
--sonar-url <url> SonarQube base URL (optional — omit for standalone mode)
|
|
365
523
|
--sonar-token <token> Sonar API token
|
|
366
524
|
--project-key <key> Sonar project key
|
|
367
525
|
--pr <id> Pull request ID
|
|
526
|
+
--scm-provider <provider> SCM provider: bitbucket (default) or github
|
|
368
527
|
--bitbucket-token <token> Bitbucket API token
|
|
369
|
-
--
|
|
528
|
+
--bitbucket-url <url> Bitbucket base URL (self-hosted)
|
|
529
|
+
--repo <repo> workspace/repo-slug (Bitbucket)
|
|
530
|
+
--github-token <token> GitHub API token
|
|
531
|
+
--github-repo <repo> owner/repo (GitHub)
|
|
532
|
+
--github-url <url> GitHub Enterprise base URL (self-hosted)
|
|
533
|
+
--min-severity <level> Minimum issue severity: BLOCKER, CRITICAL, MAJOR, MINOR, INFO (default: CRITICAL)
|
|
370
534
|
--ai-provider <provider> AI provider (default: openai)
|
|
371
535
|
--ai-model <model> AI model (default: gpt-4o-mini)
|
|
372
|
-
--
|
|
536
|
+
--slack-webhook <url> Slack incoming webhook URL for notifications
|
|
537
|
+
--teams-webhook <url> Microsoft Teams webhook URL for notifications
|
|
373
538
|
--dry-run Print to terminal instead of posting
|
|
374
539
|
--jira-url <url> JIRA base URL
|
|
375
540
|
--jira-email <email> JIRA account email
|
|
@@ -389,19 +554,24 @@ src/
|
|
|
389
554
|
riskScorer.ts Calculates PR risk score from 5 factors
|
|
390
555
|
complexityAnalyzer.ts Fetches and analyzes code complexity metrics
|
|
391
556
|
acceptanceValidator.ts Validates JIRA acceptance criteria using AI
|
|
557
|
+
summaryBuilder.ts Builds formatted summary comments for PRs
|
|
392
558
|
ai/
|
|
393
559
|
aiClient.ts Pluggable AI provider (OpenAI for now)
|
|
394
560
|
promptBuilder.ts Builds structured prompts per issue
|
|
395
561
|
scm/
|
|
396
|
-
bitbucket.ts Posts inline PR comments
|
|
562
|
+
bitbucket.ts Posts inline PR comments to Bitbucket
|
|
563
|
+
github.ts Posts inline PR comments to GitHub
|
|
564
|
+
commentTracker.ts Tracks existing comments for deduplication
|
|
397
565
|
integrations/
|
|
398
566
|
jiraClient.ts JIRA REST API client
|
|
567
|
+
notifier.ts Sends review summaries to Slack and Teams
|
|
399
568
|
frameworks/
|
|
400
569
|
detector.ts Auto-detects React, Angular, Vue, NestJS, Node
|
|
401
570
|
utils/
|
|
402
571
|
retry.ts Exponential backoff with jitter
|
|
403
572
|
concurrency.ts Caps parallel AI calls (default: 3)
|
|
404
573
|
env.ts Resolves config from env vars and CLI flags
|
|
574
|
+
configFile.ts Loads .irarc.json or ira.config.json from project root
|
|
405
575
|
types/
|
|
406
576
|
config.ts All config interfaces
|
|
407
577
|
sonar.ts Sonar API types
|
|
@@ -412,7 +582,7 @@ src/
|
|
|
412
582
|
|
|
413
583
|
## Built-in reliability
|
|
414
584
|
|
|
415
|
-
All external API calls to Sonar, OpenAI, Bitbucket, and JIRA automatically retry up to 3 times with exponential backoff. AI calls run with a concurrency limit of 3 so you don't hit rate limits. If something optional like complexity analysis
|
|
585
|
+
All external API calls to Sonar, OpenAI, Bitbucket, GitHub, and JIRA automatically retry up to 3 times with exponential backoff. AI calls run with a concurrency limit of 3 so you don't hit rate limits. If something optional like complexity analysis, JIRA validation, or notifications fails, the review still completes and the failure shows up as a warning instead of crashing the whole run. You don't need to configure any of this.
|
|
416
586
|
|
|
417
587
|
## Security
|
|
418
588
|
|
|
@@ -421,7 +591,7 @@ Your tokens are safe.
|
|
|
421
591
|
- IRA runs on your servers, not ours. It's just an npm package. When it runs in your CI/CD pipeline, your tokens stay in your infrastructure. The package author has zero access to them.
|
|
422
592
|
- The code is fully open source. Every line is auditable. Tokens are only used in `Authorization` headers to APIs you already own.
|
|
423
593
|
- Only compiled code ships to npm. No source files, no config, no secrets. Just the `dist/` folder.
|
|
424
|
-
- There's no telemetry, no analytics, and no tracking. The only network calls IRA makes are to the APIs you explicitly configure: Sonar, OpenAI, Bitbucket, and optionally JIRA.
|
|
594
|
+
- There's no telemetry, no analytics, and no tracking. The only network calls IRA makes are to the APIs you explicitly configure: Sonar, OpenAI, Bitbucket/GitHub, and optionally JIRA, Slack, and Teams.
|
|
425
595
|
|
|
426
596
|
Think of it like ESLint or the AWS CLI. You install it, give it your credentials at runtime, and it does its job. Nobody else sees your data.
|
|
427
597
|
|
|
@@ -430,7 +600,7 @@ Think of it like ESLint or the AWS CLI. You install it, give it your credentials
|
|
|
430
600
|
```bash
|
|
431
601
|
npm install # install deps
|
|
432
602
|
npm run typecheck # type check
|
|
433
|
-
npm test # run all
|
|
603
|
+
npm test # run all tests
|
|
434
604
|
npm run test:watch # watch mode
|
|
435
605
|
npm run build # build ESM + CJS + types
|
|
436
606
|
```
|
|
@@ -438,10 +608,11 @@ npm run build # build ESM + CJS + types
|
|
|
438
608
|
## Requirements
|
|
439
609
|
|
|
440
610
|
- Node.js 18+
|
|
441
|
-
- A SonarQube or SonarCloud project with PR analysis enabled
|
|
442
611
|
- An OpenAI API key (pay-per-use, not free tier)
|
|
443
|
-
- A Bitbucket repo with an open pull request
|
|
612
|
+
- A Bitbucket or GitHub repo with an open pull request
|
|
613
|
+
- SonarQube or SonarCloud project with PR analysis enabled (optional — IRA works without it)
|
|
444
614
|
- JIRA Cloud instance for acceptance criteria validation (optional)
|
|
615
|
+
- Slack/Teams webhook URLs for notifications (optional)
|
|
445
616
|
|
|
446
617
|
## License
|
|
447
618
|
|