ira-review 0.2.0 → 0.3.1
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 +226 -56
- package/README.md +69 -25
- package/README.npm.md +69 -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,48 @@ 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 for **non-secret settings only**:
|
|
255
|
+
|
|
256
|
+
```json
|
|
257
|
+
{
|
|
258
|
+
"sonarUrl": "https://sonarcloud.io",
|
|
259
|
+
"projectKey": "my-org_my-project",
|
|
260
|
+
"scmProvider": "github",
|
|
261
|
+
"githubRepo": "owner/repo",
|
|
262
|
+
"minSeverity": "MAJOR",
|
|
263
|
+
"dryRun": false
|
|
264
|
+
}
|
|
265
|
+
```
|
|
266
|
+
|
|
267
|
+
**⚠️ Never put tokens or API keys in config files.** IRA doesn't store your secrets — that's by design. All tokens (`sonarToken`, `githubToken`, `bitbucketToken`, `aiApiKey`, `jiraToken`) should come from environment variables or CI/CD secrets. The config file is for non-sensitive defaults like URLs, repo names, severity levels, and feature flags.
|
|
268
|
+
|
|
269
|
+
**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.
|
|
270
|
+
|
|
184
271
|
## PR risk scoring
|
|
185
272
|
|
|
186
273
|
Every review automatically calculates a risk score based on five factors:
|
|
@@ -210,7 +297,7 @@ In dry-run mode you'll see something like:
|
|
|
210
297
|
|
|
211
298
|
## Code complexity insights
|
|
212
299
|
|
|
213
|
-
IRA fetches complexity metrics from SonarQube's measures API and flags the files that need attention:
|
|
300
|
+
IRA fetches complexity metrics from SonarQube's measures API (when configured) and flags the files that need attention:
|
|
214
301
|
|
|
215
302
|
- **Cyclomatic complexity** tells you how many paths exist through the code
|
|
216
303
|
- **Cognitive complexity** tells you how hard it is to understand
|
|
@@ -218,15 +305,40 @@ IRA fetches complexity metrics from SonarQube's measures API and flags the files
|
|
|
218
305
|
|
|
219
306
|
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
307
|
|
|
308
|
+
## Summary comments
|
|
309
|
+
|
|
310
|
+
IRA posts a formatted summary comment on every PR with:
|
|
311
|
+
|
|
312
|
+
- **Risk score** — the overall risk level with a breakdown of contributing factors
|
|
313
|
+
- **Overview** — a high-level summary of what the review found
|
|
314
|
+
- **Complexity hotspots** — files with high cyclomatic or cognitive complexity
|
|
315
|
+
- **JIRA AC results** — pass/fail status for each acceptance criterion (if JIRA is configured)
|
|
316
|
+
|
|
317
|
+
This gives reviewers a quick at-a-glance view without scrolling through individual inline comments.
|
|
318
|
+
|
|
319
|
+
## Comment deduplication
|
|
320
|
+
|
|
321
|
+
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.
|
|
322
|
+
|
|
323
|
+
## Slack and Teams notifications
|
|
324
|
+
|
|
325
|
+
Send review summaries to your team's channels by providing webhook URLs:
|
|
326
|
+
|
|
327
|
+
```bash
|
|
328
|
+
npx ira-review review \
|
|
329
|
+
--pr 42 \
|
|
330
|
+
--slack-webhook https://hooks.slack.com/services/xxx/yyy/zzz \
|
|
331
|
+
--teams-webhook https://outlook.office.com/webhook/xxx
|
|
332
|
+
```
|
|
333
|
+
|
|
334
|
+
Both can be used at the same time. The notification includes the risk score, issue count, and a link back to the PR.
|
|
335
|
+
|
|
221
336
|
## JIRA acceptance criteria validation
|
|
222
337
|
|
|
223
338
|
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
339
|
|
|
225
340
|
```bash
|
|
226
341
|
npx ira-review review \
|
|
227
|
-
--sonar-url https://sonarcloud.io \
|
|
228
|
-
--sonar-token sqa_xxxxx \
|
|
229
|
-
--project-key my-org_my-project \
|
|
230
342
|
--pr 42 \
|
|
231
343
|
--jira-url https://yourcompany.atlassian.net \
|
|
232
344
|
--jira-email dev@company.com \
|
|
@@ -235,7 +347,7 @@ npx ira-review review \
|
|
|
235
347
|
--dry-run
|
|
236
348
|
```
|
|
237
349
|
|
|
238
|
-
IRA fetches the JIRA ticket, pulls out the acceptance criteria, and uses AI to check each one against the
|
|
350
|
+
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
351
|
|
|
240
352
|
```
|
|
241
353
|
✅ JIRA Acceptance: PROJ-123 - Add user authentication
|
|
@@ -261,21 +373,24 @@ If you want more control, you can use IRA programmatically instead of the CLI:
|
|
|
261
373
|
import { ReviewEngine } from "ira-review";
|
|
262
374
|
|
|
263
375
|
const engine = new ReviewEngine({
|
|
376
|
+
// SonarQube is optional — omit to run in standalone mode
|
|
264
377
|
sonar: {
|
|
265
378
|
baseUrl: "https://sonarcloud.io",
|
|
266
379
|
token: "sqa_xxxxx",
|
|
267
380
|
projectKey: "my-org_my-project",
|
|
268
381
|
},
|
|
382
|
+
scmProvider: "github", // "bitbucket" (default) or "github"
|
|
269
383
|
scm: {
|
|
270
|
-
token: "
|
|
271
|
-
|
|
272
|
-
|
|
384
|
+
token: "ghp_xxxxx",
|
|
385
|
+
owner: "my-org",
|
|
386
|
+
repo: "my-repo",
|
|
273
387
|
},
|
|
274
388
|
ai: {
|
|
275
389
|
provider: "openai",
|
|
276
390
|
apiKey: process.env.OPENAI_API_KEY!,
|
|
277
391
|
},
|
|
278
392
|
pullRequestId: "42",
|
|
393
|
+
minSeverity: "MAJOR",
|
|
279
394
|
// Optional JIRA integration
|
|
280
395
|
jira: {
|
|
281
396
|
baseUrl: "https://yourcompany.atlassian.net",
|
|
@@ -283,6 +398,11 @@ const engine = new ReviewEngine({
|
|
|
283
398
|
token: "jira_xxxxx",
|
|
284
399
|
},
|
|
285
400
|
jiraTicket: "PROJ-123",
|
|
401
|
+
// Optional notifications
|
|
402
|
+
notifications: {
|
|
403
|
+
slackWebhookUrl: "https://hooks.slack.com/services/xxx/yyy/zzz",
|
|
404
|
+
teamsWebhookUrl: "https://outlook.office.com/webhook/xxx",
|
|
405
|
+
},
|
|
286
406
|
});
|
|
287
407
|
|
|
288
408
|
const result = await engine.run();
|
|
@@ -296,27 +416,34 @@ If you just want to preview without posting anything, add `dryRun: true` to the
|
|
|
296
416
|
|
|
297
417
|
## Environment variables
|
|
298
418
|
|
|
299
|
-
If you're tired of passing flags every time, set these environment variables instead. CLI flags
|
|
419
|
+
If you're tired of passing flags every time, set these environment variables instead. CLI flags and config file values still take priority.
|
|
300
420
|
|
|
301
421
|
| Variable | What it does |
|
|
302
422
|
|---|---|
|
|
303
423
|
| `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 |
|
|
424
|
+
| `IRA_SONAR_URL` | SonarQube/SonarCloud URL (optional) |
|
|
425
|
+
| `IRA_SONAR_TOKEN` | Sonar API token (optional) |
|
|
426
|
+
| `IRA_PROJECT_KEY` | Sonar project key (optional) |
|
|
307
427
|
| `IRA_PR` | Pull request ID |
|
|
428
|
+
| `IRA_SCM_PROVIDER` | `bitbucket` (default) or `github` |
|
|
308
429
|
| `IRA_BITBUCKET_TOKEN` | Bitbucket API token |
|
|
309
430
|
| `IRA_BITBUCKET_URL` | Bitbucket Server URL (only for self-hosted) |
|
|
310
431
|
| `IRA_REPO` | `workspace/repo-slug` format |
|
|
432
|
+
| `IRA_GITHUB_TOKEN` | GitHub API token |
|
|
433
|
+
| `IRA_GITHUB_REPO` | `owner/repo` format |
|
|
434
|
+
| `IRA_GITHUB_URL` | GitHub Enterprise URL (only for self-hosted) |
|
|
435
|
+
| `IRA_MIN_SEVERITY` | Minimum severity to include: `BLOCKER`, `CRITICAL`, `MAJOR`, `MINOR`, `INFO` (default: `CRITICAL`) |
|
|
436
|
+
| `IRA_SLACK_WEBHOOK` | Slack incoming webhook URL (optional) |
|
|
437
|
+
| `IRA_TEAMS_WEBHOOK` | Microsoft Teams webhook URL (optional) |
|
|
311
438
|
| `IRA_JIRA_URL` | JIRA base URL (optional) |
|
|
312
439
|
| `IRA_JIRA_EMAIL` | JIRA account email (optional) |
|
|
313
440
|
| `IRA_JIRA_TOKEN` | JIRA API token (optional) |
|
|
314
441
|
|
|
315
442
|
You can also copy `.env.example` to `.env` and fill in the values there.
|
|
316
443
|
|
|
317
|
-
## CI/CD
|
|
444
|
+
## CI/CD examples
|
|
318
445
|
|
|
319
|
-
|
|
446
|
+
### Bitbucket Pipelines
|
|
320
447
|
|
|
321
448
|
```yaml
|
|
322
449
|
pipelines:
|
|
@@ -334,6 +461,36 @@ pipelines:
|
|
|
334
461
|
IRA_BITBUCKET_TOKEN: $BB_TOKEN
|
|
335
462
|
```
|
|
336
463
|
|
|
464
|
+
### GitHub Actions
|
|
465
|
+
|
|
466
|
+
```yaml
|
|
467
|
+
name: AI Code Review
|
|
468
|
+
on:
|
|
469
|
+
pull_request:
|
|
470
|
+
types: [opened, synchronize]
|
|
471
|
+
|
|
472
|
+
jobs:
|
|
473
|
+
review:
|
|
474
|
+
runs-on: ubuntu-latest
|
|
475
|
+
steps:
|
|
476
|
+
- uses: actions/setup-node@v4
|
|
477
|
+
with:
|
|
478
|
+
node-version: 20
|
|
479
|
+
- run: |
|
|
480
|
+
npx ira-review review \
|
|
481
|
+
--pr ${{ github.event.pull_request.number }} \
|
|
482
|
+
--scm-provider github \
|
|
483
|
+
--github-token ${{ secrets.GITHUB_TOKEN }} \
|
|
484
|
+
--github-repo ${{ github.repository }}
|
|
485
|
+
env:
|
|
486
|
+
OPENAI_API_KEY: ${{ secrets.OPENAI_API_KEY }}
|
|
487
|
+
IRA_SONAR_URL: ${{ secrets.SONAR_URL }}
|
|
488
|
+
IRA_SONAR_TOKEN: ${{ secrets.SONAR_TOKEN }}
|
|
489
|
+
IRA_PROJECT_KEY: ${{ secrets.SONAR_PROJECT_KEY }}
|
|
490
|
+
```
|
|
491
|
+
|
|
492
|
+
Remove the `IRA_SONAR_*` variables to run in standalone mode without SonarQube.
|
|
493
|
+
|
|
337
494
|
All tokens come from your pipeline's secret variables. IRA never stores or transmits them anywhere else.
|
|
338
495
|
|
|
339
496
|
## What the comments look like
|
|
@@ -361,15 +518,22 @@ variable is needed later, move the declaration to where it's first used.
|
|
|
361
518
|
ira-review review [options]
|
|
362
519
|
|
|
363
520
|
Options:
|
|
364
|
-
--sonar-url <url> SonarQube base URL
|
|
521
|
+
--sonar-url <url> SonarQube base URL (optional — omit for standalone mode)
|
|
365
522
|
--sonar-token <token> Sonar API token
|
|
366
523
|
--project-key <key> Sonar project key
|
|
367
524
|
--pr <id> Pull request ID
|
|
525
|
+
--scm-provider <provider> SCM provider: bitbucket (default) or github
|
|
368
526
|
--bitbucket-token <token> Bitbucket API token
|
|
369
|
-
--
|
|
527
|
+
--bitbucket-url <url> Bitbucket base URL (self-hosted)
|
|
528
|
+
--repo <repo> workspace/repo-slug (Bitbucket)
|
|
529
|
+
--github-token <token> GitHub API token
|
|
530
|
+
--github-repo <repo> owner/repo (GitHub)
|
|
531
|
+
--github-url <url> GitHub Enterprise base URL (self-hosted)
|
|
532
|
+
--min-severity <level> Minimum issue severity: BLOCKER, CRITICAL, MAJOR, MINOR, INFO (default: CRITICAL)
|
|
370
533
|
--ai-provider <provider> AI provider (default: openai)
|
|
371
534
|
--ai-model <model> AI model (default: gpt-4o-mini)
|
|
372
|
-
--
|
|
535
|
+
--slack-webhook <url> Slack incoming webhook URL for notifications
|
|
536
|
+
--teams-webhook <url> Microsoft Teams webhook URL for notifications
|
|
373
537
|
--dry-run Print to terminal instead of posting
|
|
374
538
|
--jira-url <url> JIRA base URL
|
|
375
539
|
--jira-email <email> JIRA account email
|
|
@@ -389,19 +553,24 @@ src/
|
|
|
389
553
|
riskScorer.ts Calculates PR risk score from 5 factors
|
|
390
554
|
complexityAnalyzer.ts Fetches and analyzes code complexity metrics
|
|
391
555
|
acceptanceValidator.ts Validates JIRA acceptance criteria using AI
|
|
556
|
+
summaryBuilder.ts Builds formatted summary comments for PRs
|
|
392
557
|
ai/
|
|
393
558
|
aiClient.ts Pluggable AI provider (OpenAI for now)
|
|
394
559
|
promptBuilder.ts Builds structured prompts per issue
|
|
395
560
|
scm/
|
|
396
|
-
bitbucket.ts Posts inline PR comments
|
|
561
|
+
bitbucket.ts Posts inline PR comments to Bitbucket
|
|
562
|
+
github.ts Posts inline PR comments to GitHub
|
|
563
|
+
commentTracker.ts Tracks existing comments for deduplication
|
|
397
564
|
integrations/
|
|
398
565
|
jiraClient.ts JIRA REST API client
|
|
566
|
+
notifier.ts Sends review summaries to Slack and Teams
|
|
399
567
|
frameworks/
|
|
400
568
|
detector.ts Auto-detects React, Angular, Vue, NestJS, Node
|
|
401
569
|
utils/
|
|
402
570
|
retry.ts Exponential backoff with jitter
|
|
403
571
|
concurrency.ts Caps parallel AI calls (default: 3)
|
|
404
572
|
env.ts Resolves config from env vars and CLI flags
|
|
573
|
+
configFile.ts Loads .irarc.json or ira.config.json from project root
|
|
405
574
|
types/
|
|
406
575
|
config.ts All config interfaces
|
|
407
576
|
sonar.ts Sonar API types
|
|
@@ -412,7 +581,7 @@ src/
|
|
|
412
581
|
|
|
413
582
|
## Built-in reliability
|
|
414
583
|
|
|
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
|
|
584
|
+
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
585
|
|
|
417
586
|
## Security
|
|
418
587
|
|
|
@@ -421,7 +590,7 @@ Your tokens are safe.
|
|
|
421
590
|
- 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
591
|
- The code is fully open source. Every line is auditable. Tokens are only used in `Authorization` headers to APIs you already own.
|
|
423
592
|
- 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.
|
|
593
|
+
- 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
594
|
|
|
426
595
|
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
596
|
|
|
@@ -430,7 +599,7 @@ Think of it like ESLint or the AWS CLI. You install it, give it your credentials
|
|
|
430
599
|
```bash
|
|
431
600
|
npm install # install deps
|
|
432
601
|
npm run typecheck # type check
|
|
433
|
-
npm test # run all
|
|
602
|
+
npm test # run all tests
|
|
434
603
|
npm run test:watch # watch mode
|
|
435
604
|
npm run build # build ESM + CJS + types
|
|
436
605
|
```
|
|
@@ -438,10 +607,11 @@ npm run build # build ESM + CJS + types
|
|
|
438
607
|
## Requirements
|
|
439
608
|
|
|
440
609
|
- Node.js 18+
|
|
441
|
-
- A SonarQube or SonarCloud project with PR analysis enabled
|
|
442
610
|
- An OpenAI API key (pay-per-use, not free tier)
|
|
443
|
-
- A Bitbucket repo with an open pull request
|
|
611
|
+
- A Bitbucket or GitHub repo with an open pull request
|
|
612
|
+
- SonarQube or SonarCloud project with PR analysis enabled (optional — IRA works without it)
|
|
444
613
|
- JIRA Cloud instance for acceptance criteria validation (optional)
|
|
614
|
+
- Slack/Teams webhook URLs for notifications (optional)
|
|
445
615
|
|
|
446
616
|
## License
|
|
447
617
|
|