@ateriss_/aiv-cli 1.0.1 → 1.0.2
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.md +78 -63
- package/dist/index.js +330 -110
- package/package.json +10 -3
- package/src/cli/commands/review.ts +89 -41
- package/src/cli/renderer.ts +61 -0
- package/src/cli/selector.ts +6 -5
- package/src/git/github.ts +33 -1
- package/src/i18n/en.ts +7 -0
- package/src/i18n/es.ts +7 -0
- package/tsup.config.ts +1 -0
package/README.md
CHANGED
|
@@ -1,20 +1,42 @@
|
|
|
1
1
|
# aiv — AI PR Reviewer
|
|
2
2
|
|
|
3
|
-
A local-first, multi-agent CLI for reviewing GitHub pull requests using any supported AI provider. Runs three specialized agents in parallel (Business, Architecture, Security) and produces a structured risk report with findings, suggestions, and an executive summary.
|
|
4
|
-
|
|
5
3
|
```
|
|
6
4
|
█████╗ ██╗ ██████╗ ██████╗ ██████╗ ███████╗██╗ ██╗██╗███████╗██╗ ██╗███████╗██████╗
|
|
7
5
|
██╔══██╗██║ ██╔══██╗██╔══██╗ ██╔══██╗██╔════╝██║ ██║██║██╔════╝██║ ██║██╔════╝██╔══██╗
|
|
8
6
|
███████║██║ ██████╔╝██████╔╝ ██████╔╝█████╗ ██║ ██║██║█████╗ ██║ █╗ ██║█████╗ ██████╔╝
|
|
9
7
|
██╔══██║██║ ██╔═══╝ ██╔══██╗ ██╔══██╗██╔══╝ ╚██╗ ██╔╝██║██╔══╝ ██║███╗██║██╔══╝ ██╔══██╗
|
|
10
8
|
██║ ██║██║ ██║ ██║ ██║ ██║ ██║███████╗ ╚████╔╝ ██║███████╗╚███╔███╔╝███████╗██║ ██║
|
|
11
|
-
╚═╝ ╚═╝╚═╝ ╚═╝ ╚═╝ ╚═╝ ╚═╝ ╚═╝╚══════╝ ╚═══╝ ╚═╝╚══════╝ ╚══╝╚══╝ ╚══════╝╚═╝
|
|
9
|
+
╚═╝ ╚═╝╚═╝ ╚═╝ ╚═╝ ╚═╝ ╚═╝ ╚═╝╚══════╝ ╚═══╝ ╚═╝╚══════╝ ╚══╝╚══╝ ╚══════╝╚═╝ ╚═╝
|
|
12
10
|
|
|
13
11
|
by Ateriss
|
|
14
12
|
```
|
|
15
13
|
|
|
16
14
|
---
|
|
17
15
|
|
|
16
|
+
## What is aiv?
|
|
17
|
+
|
|
18
|
+
Code review is one of the most important quality gates in a software team — and also one of the most time-consuming. Reviewers need to understand the business context, track architectural decisions, spot security risks, and catch regressions, all while reading through a diff that may span dozens of files.
|
|
19
|
+
|
|
20
|
+
**aiv** is a local-first CLI that runs that analysis for you, before a human ever opens the PR.
|
|
21
|
+
|
|
22
|
+
It sends the diff to three specialized AI agents in parallel — one focused on **business logic and domain rules**, one on **architecture and structural patterns**, and one on **security vulnerabilities** — and returns a structured risk report with severity-rated findings, specific suggestions per file, and an executive summary. The report is anchored to your project: aiv reads your `context.md` (project background, architecture decisions, sensitive zones) and `rules.yml` (custom business rules, required calls, forbidden patterns) so findings are relevant to your codebase, not just generic linting advice.
|
|
23
|
+
|
|
24
|
+
**What aiv catches that linters miss:**
|
|
25
|
+
|
|
26
|
+
- A retry loop that could cause duplicate charges because it skips the idempotency check your team agreed on
|
|
27
|
+
- A service that imports directly from a handler, breaking the layer contract
|
|
28
|
+
- A new endpoint that reads user data without going through the authorization middleware
|
|
29
|
+
- A payroll mutation that doesn't call `auditLog()` as required by your rules
|
|
30
|
+
- A function moved to a shared module that now exposes internal state to layers that shouldn't see it
|
|
31
|
+
|
|
32
|
+
**What happens after the review:**
|
|
33
|
+
|
|
34
|
+
Once the report is in, aiv lets you act on it directly from the terminal — approve the PR, request changes, post the full report as a formatted GitHub comment, or merge with your preferred strategy (squash, merge, rebase). If you've already reviewed the PR in a previous session, aiv detects the cached analysis in the PR comments and asks if you want to reuse it instead of re-running the agents.
|
|
35
|
+
|
|
36
|
+
**Works with any AI provider.** Claude, OpenAI, Gemini, Groq, Mistral, DeepSeek, Kimi, Ollama, or any OpenAI-compatible endpoint. Mix providers per agent — use a fast model for routine checks and a powerful one for security. Configure a fallback chain so a quota error on one provider silently switches to the next without losing the run.
|
|
37
|
+
|
|
38
|
+
---
|
|
39
|
+
|
|
18
40
|
## Table of Contents
|
|
19
41
|
|
|
20
42
|
- [Requirements](#requirements)
|
|
@@ -106,7 +128,7 @@ aiv prs
|
|
|
106
128
|
aiv review 42
|
|
107
129
|
```
|
|
108
130
|
|
|
109
|
-
After the report, aiv asks if you want to
|
|
131
|
+
After the report, aiv asks if you want to approve, request changes, post the report as a PR comment, or merge directly from the terminal.
|
|
110
132
|
|
|
111
133
|
---
|
|
112
134
|
|
|
@@ -207,7 +229,7 @@ aiv review 42 --agent business architecture
|
|
|
207
229
|
aiv review 42 --json # raw JSON, no interactive prompt
|
|
208
230
|
```
|
|
209
231
|
|
|
210
|
-
|
|
232
|
+
If a previous aiv analysis exists as a comment on the PR, aiv asks whether to reuse it or run a fresh analysis. After the report, the post-review action menu lets you approve, request changes, post the report as a comment, or skip.
|
|
211
233
|
|
|
212
234
|
---
|
|
213
235
|
|
|
@@ -359,13 +381,15 @@ business_rules:
|
|
|
359
381
|
- directDbWrite
|
|
360
382
|
```
|
|
361
383
|
|
|
384
|
+
The more specific your rules, the fewer false positives and the more actionable the findings.
|
|
385
|
+
|
|
362
386
|
---
|
|
363
387
|
|
|
364
388
|
### Context
|
|
365
389
|
|
|
366
390
|
`.aiv/context.md` — project background that agents read before analyzing the diff.
|
|
367
391
|
|
|
368
|
-
Auto-generated by `aiv init`, `aiv context refresh`, and `aiv context generate`. You can edit it freely —
|
|
392
|
+
Auto-generated by `aiv init`, `aiv context refresh`, and `aiv context generate`. You can edit it freely — the richer this file, the more accurate the findings.
|
|
369
393
|
|
|
370
394
|
```markdown
|
|
371
395
|
## Business Context
|
|
@@ -385,8 +409,6 @@ Services must not import from handlers.
|
|
|
385
409
|
- src/payments/ — Stripe integration, never bypass PaymentGateway
|
|
386
410
|
```
|
|
387
411
|
|
|
388
|
-
The richer this file, the more accurate the agent findings.
|
|
389
|
-
|
|
390
412
|
---
|
|
391
413
|
|
|
392
414
|
## GitHub Account Management
|
|
@@ -489,7 +511,7 @@ gemini:
|
|
|
489
511
|
|
|
490
512
|
### OpenAI-compatible providers
|
|
491
513
|
|
|
492
|
-
Any provider that exposes an OpenAI-compatible API can be registered with one command — no code changes
|
|
514
|
+
Any provider that exposes an OpenAI-compatible API can be registered with one command — no code changes needed when new providers launch.
|
|
493
515
|
|
|
494
516
|
```bash
|
|
495
517
|
# Kimi (Moonshot AI)
|
|
@@ -527,12 +549,6 @@ aiv config add-provider ollama \
|
|
|
527
549
|
--base-url http://localhost:11434/v1 \
|
|
528
550
|
--api-key-env OLLAMA_API_KEY \
|
|
529
551
|
--model llama3.2
|
|
530
|
-
|
|
531
|
-
# Any future provider that adopts the OpenAI spec
|
|
532
|
-
aiv config add-provider newprovider \
|
|
533
|
-
--base-url https://api.newprovider.com/v1 \
|
|
534
|
-
--api-key-env NEWPROVIDER_API_KEY \
|
|
535
|
-
--model their-model-name
|
|
536
552
|
```
|
|
537
553
|
|
|
538
554
|
Once registered, custom providers work exactly like built-ins:
|
|
@@ -551,7 +567,6 @@ aiv config add-provider kimi --model moonshot-v1-32k --force # update
|
|
|
551
567
|
Each agent (and the context generator) can use a different provider or model:
|
|
552
568
|
|
|
553
569
|
```bash
|
|
554
|
-
# Assign provider/model per agent
|
|
555
570
|
aiv config set-agent-provider business claude/claude-sonnet-4-6
|
|
556
571
|
aiv config set-agent-provider security openai/gpt-4.1
|
|
557
572
|
aiv config set-agent-provider architecture gemini/gemini-2.0-flash
|
|
@@ -569,8 +584,6 @@ aiv config set-agent-provider business --clear
|
|
|
569
584
|
|
|
570
585
|
Valid agent roles: `business`, `architecture`, `security`, `context`.
|
|
571
586
|
|
|
572
|
-
The `context` role is used by `aiv context generate`. All other roles map to the review agents.
|
|
573
|
-
|
|
574
587
|
---
|
|
575
588
|
|
|
576
589
|
### Fallback chain
|
|
@@ -675,11 +688,12 @@ After every review in an interactive terminal, aiv asks:
|
|
|
675
688
|
? What would you like to do with this PR?
|
|
676
689
|
❯ ✔ Approve PR
|
|
677
690
|
⚑ Request Changes
|
|
691
|
+
💬 Post as PR comment
|
|
678
692
|
────────────────────────────────────────
|
|
679
693
|
↩ Skip
|
|
680
694
|
```
|
|
681
695
|
|
|
682
|
-
- **Approve** — submits an `APPROVE` review to GitHub
|
|
696
|
+
- **Approve** — submits an `APPROVE` review to GitHub, then asks if you want to merge:
|
|
683
697
|
|
|
684
698
|
```
|
|
685
699
|
? Merge this PR now? (y/N)
|
|
@@ -693,8 +707,20 @@ After every review in an interactive terminal, aiv asks:
|
|
|
693
707
|
After approving (with or without merge), `context.md` and `tree.json` are refreshed automatically.
|
|
694
708
|
|
|
695
709
|
- **Request Changes** — submits a `REQUEST_CHANGES` review to GitHub.
|
|
710
|
+
- **Post as PR comment** — publishes the full report as a formatted GitHub comment. The comment includes severity-rated findings, suggestions, and agent summaries. It also embeds the analysis data so aiv can detect it on future runs.
|
|
696
711
|
- **Skip** — does nothing, exits cleanly.
|
|
697
712
|
|
|
713
|
+
### Analysis cache
|
|
714
|
+
|
|
715
|
+
When you run `aiv review` on a PR that already has an aiv comment, aiv detects the previous analysis and asks:
|
|
716
|
+
|
|
717
|
+
```
|
|
718
|
+
Found a previous aiv analysis on this PR.
|
|
719
|
+
? Use cached analysis? (Y/n)
|
|
720
|
+
```
|
|
721
|
+
|
|
722
|
+
Choosing yes skips the AI agents entirely and uses the stored result — no API calls, instant output. Choose no to run a fresh analysis (useful after new commits are pushed).
|
|
723
|
+
|
|
698
724
|
---
|
|
699
725
|
|
|
700
726
|
## Multi-language
|
|
@@ -728,19 +754,14 @@ AIV_LANG=es aiv prs # per-session override
|
|
|
728
754
|
| `AIV_LANG` | No | Override display language (`en` or `es`) |
|
|
729
755
|
| `LANG` | No | System locale (auto-detected by aiv) |
|
|
730
756
|
|
|
731
|
-
For custom providers, the env var name is whatever you passed to `--api-key-env
|
|
732
|
-
|
|
733
|
-
```bash
|
|
734
|
-
export KIMI_API_KEY=sk-...
|
|
735
|
-
aiv config add-provider kimi --api-key-env KIMI_API_KEY ...
|
|
736
|
-
```
|
|
757
|
+
For custom providers, the env var name is whatever you passed to `--api-key-env`.
|
|
737
758
|
|
|
738
759
|
### GitHub token permissions
|
|
739
760
|
|
|
740
761
|
| Scope | Required for |
|
|
741
762
|
|-------|-------------|
|
|
742
763
|
| `repo` (private repos) or `public_repo` | Reading PRs and diffs |
|
|
743
|
-
| `pull_requests: write` (fine-grained PAT) | Submitting reviews
|
|
764
|
+
| `pull_requests: write` (fine-grained PAT) | Submitting reviews, posting comments, merging |
|
|
744
765
|
|
|
745
766
|
---
|
|
746
767
|
|
|
@@ -758,14 +779,18 @@ cd your-repo && aiv init
|
|
|
758
779
|
|
|
759
780
|
### `Missing env var: GITHUB_TOKEN (account: default)`
|
|
760
781
|
|
|
761
|
-
The token env var for the active account is not set.
|
|
782
|
+
The token env var for the active account is not set. Check which variable name the account expects:
|
|
762
783
|
|
|
763
784
|
```bash
|
|
764
|
-
export GITHUB_TOKEN=ghp_...
|
|
765
|
-
# or check which account/var is active:
|
|
766
785
|
aiv config accounts
|
|
767
786
|
```
|
|
768
787
|
|
|
788
|
+
Then set it (once, permanently on Windows):
|
|
789
|
+
|
|
790
|
+
```powershell
|
|
791
|
+
[System.Environment]::SetEnvironmentVariable("GITHUB_TOKEN", "ghp_...", "User")
|
|
792
|
+
```
|
|
793
|
+
|
|
769
794
|
---
|
|
770
795
|
|
|
771
796
|
### `Missing env var: CLAUDE_API_KEY`
|
|
@@ -780,10 +805,8 @@ aiv config set-provider openai
|
|
|
780
805
|
|
|
781
806
|
### `Unknown provider: "xyz".`
|
|
782
807
|
|
|
783
|
-
A provider name was used that isn't registered.
|
|
784
|
-
|
|
785
808
|
```bash
|
|
786
|
-
aiv config list-providers
|
|
809
|
+
aiv config list-providers
|
|
787
810
|
aiv config add-provider xyz --base-url <url> --api-key-env XYZ_API_KEY --model <model>
|
|
788
811
|
```
|
|
789
812
|
|
|
@@ -791,8 +814,6 @@ aiv config add-provider xyz --base-url <url> --api-key-env XYZ_API_KEY --model <
|
|
|
791
814
|
|
|
792
815
|
### `Could not detect GitHub owner/repo.`
|
|
793
816
|
|
|
794
|
-
The git remote is missing or not a GitHub URL.
|
|
795
|
-
|
|
796
817
|
```bash
|
|
797
818
|
aiv prs --owner myorg --repo myrepo
|
|
798
819
|
# or set permanently:
|
|
@@ -801,21 +822,12 @@ aiv config set-repo myorg myrepo
|
|
|
801
822
|
|
|
802
823
|
---
|
|
803
824
|
|
|
804
|
-
### `Account "xyz" not found.`
|
|
805
|
-
|
|
806
|
-
```bash
|
|
807
|
-
aiv config accounts
|
|
808
|
-
aiv config add-account xyz --token-env MY_TOKEN
|
|
809
|
-
```
|
|
810
|
-
|
|
811
|
-
---
|
|
812
|
-
|
|
813
825
|
### `Failed to fetch PR: ...`
|
|
814
826
|
|
|
815
|
-
- Token lacks `repo` scope — regenerate
|
|
816
|
-
- PR number doesn't exist
|
|
817
|
-
- GitHub rate limit — wait or switch
|
|
818
|
-
- Wrong owner/repo —
|
|
827
|
+
- Token lacks `repo` scope — regenerate with the correct scopes
|
|
828
|
+
- PR number doesn't exist in this repo
|
|
829
|
+
- GitHub rate limit — wait or switch to a different account
|
|
830
|
+
- Wrong owner/repo — verify with `aiv config show`
|
|
819
831
|
|
|
820
832
|
---
|
|
821
833
|
|
|
@@ -823,10 +835,9 @@ aiv config add-account xyz --token-env MY_TOKEN
|
|
|
823
835
|
|
|
824
836
|
- API key invalid or expired
|
|
825
837
|
- Model quota exceeded — configure a [fallback chain](#fallback-chain)
|
|
826
|
-
- Diff too large — reduce `max_tokens`:
|
|
838
|
+
- Diff too large — reduce `max_tokens` in `.aiv/config.yml`:
|
|
827
839
|
|
|
828
840
|
```yaml
|
|
829
|
-
# .aiv/config.yml
|
|
830
841
|
review:
|
|
831
842
|
max_tokens: 10000
|
|
832
843
|
```
|
|
@@ -843,26 +854,30 @@ Right after `aiv init`, run:
|
|
|
843
854
|
aiv context generate
|
|
844
855
|
```
|
|
845
856
|
|
|
846
|
-
This
|
|
857
|
+
This produces a `context.md` and `rules.yml` based on what the AI infers from your project structure. Tune what it gets wrong rather than writing from scratch.
|
|
847
858
|
|
|
848
|
-
###
|
|
859
|
+
### Write specific rules
|
|
849
860
|
|
|
850
|
-
|
|
861
|
+
Generic rules produce generic findings. The more specific `rules.yml` is, the more precise the business agent becomes:
|
|
851
862
|
|
|
852
863
|
```yaml
|
|
853
864
|
business_rules:
|
|
854
865
|
orders:
|
|
855
|
-
required_calls: [validateInventory]
|
|
856
|
-
forbidden_patterns: [skipFraudCheck]
|
|
866
|
+
required_calls: [validateInventory, reserveStock]
|
|
867
|
+
forbidden_patterns: [skipFraudCheck, directInventoryWrite]
|
|
857
868
|
```
|
|
858
869
|
|
|
870
|
+
### Post the report as a PR comment
|
|
871
|
+
|
|
872
|
+
After reviewing, choose **Post as PR comment** to make the findings visible to the whole team directly in GitHub. The comment is also used as a cache — the next time anyone runs `aiv review` on the same PR, aiv detects it and offers to skip the AI calls.
|
|
873
|
+
|
|
859
874
|
### Refresh context after structural changes
|
|
860
875
|
|
|
861
876
|
```bash
|
|
862
877
|
aiv context refresh
|
|
863
878
|
```
|
|
864
879
|
|
|
865
|
-
Run after merging large refactors, adding modules, or
|
|
880
|
+
Run after merging large refactors, adding new modules, or reorganizing the project layout.
|
|
866
881
|
|
|
867
882
|
### Use a fallback chain for reliability
|
|
868
883
|
|
|
@@ -872,20 +887,20 @@ aiv config set-fallback openai gemini
|
|
|
872
887
|
|
|
873
888
|
If your primary provider is rate-limited mid-review, aiv switches automatically without losing the run.
|
|
874
889
|
|
|
875
|
-
### Match model to task
|
|
890
|
+
### Match model to task
|
|
876
891
|
|
|
877
|
-
Use a fast/cheap model for straightforward agents and a
|
|
892
|
+
Use a fast/cheap model for straightforward agents and a stronger one for the most critical:
|
|
878
893
|
|
|
879
894
|
```bash
|
|
880
895
|
aiv config set-agent-provider business claude/claude-haiku-4-5
|
|
881
896
|
aiv config set-agent-provider architecture claude/claude-haiku-4-5
|
|
882
|
-
aiv config set-agent-provider security claude/claude-sonnet-4-6
|
|
897
|
+
aiv config set-agent-provider security claude/claude-sonnet-4-6
|
|
883
898
|
```
|
|
884
899
|
|
|
885
900
|
### Use `--agent` to narrow focus
|
|
886
901
|
|
|
887
902
|
```bash
|
|
888
|
-
aiv review 101 --agent security # dependency bump
|
|
903
|
+
aiv review 101 --agent security # dependency bump — only security matters
|
|
889
904
|
aiv review 202 --agent business architecture # domain change
|
|
890
905
|
```
|
|
891
906
|
|
|
@@ -893,14 +908,14 @@ Fewer agents = faster, cheaper, more focused output.
|
|
|
893
908
|
|
|
894
909
|
### Commit `.aiv/` to the repository
|
|
895
910
|
|
|
896
|
-
Committing `config.yml`, `rules.yml`, and `context.md` means every team member gets identical review behavior with no setup. Only exclude `tree.json`:
|
|
911
|
+
Committing `config.yml`, `rules.yml`, and `context.md` means every team member gets identical review behavior with no local setup. Only exclude `tree.json`:
|
|
897
912
|
|
|
898
913
|
```
|
|
899
914
|
# .gitignore
|
|
900
915
|
.aiv/tree.json
|
|
901
916
|
```
|
|
902
917
|
|
|
903
|
-
`aiv init` adds this automatically.
|
|
918
|
+
`aiv init` adds this entry automatically.
|
|
904
919
|
|
|
905
920
|
### CI integration with `--json`
|
|
906
921
|
|
|
@@ -918,7 +933,7 @@ fi
|
|
|
918
933
|
- Not a replacement for static analysis (ESLint, SonarQube)
|
|
919
934
|
- Not a style checker
|
|
920
935
|
|
|
921
|
-
Its value is **semantic understanding**: catching business rule violations, architectural drift, and security risks that automated tools miss because they
|
|
936
|
+
Its value is **semantic understanding**: catching business rule violations, architectural drift, and security risks that automated tools miss because they don't know your project's context, rules, or intent.
|
|
922
937
|
|
|
923
938
|
---
|
|
924
939
|
|
|
@@ -930,7 +945,7 @@ src/
|
|
|
930
945
|
cli/
|
|
931
946
|
commands/ — init, prs, review, config, context, agents
|
|
932
947
|
banner.ts — ASCII welcome banner
|
|
933
|
-
renderer.ts —
|
|
948
|
+
renderer.ts — terminal renderer + GitHub comment builder
|
|
934
949
|
selector.ts — interactive PR/action picker (inquirer)
|
|
935
950
|
config/ — two-level config load/save/merge
|
|
936
951
|
context/
|