@ateriss_/aiv-cli 1.0.0 → 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 CHANGED
@@ -1,18 +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
- █████╗ ██╗██╗ ██╗
7
- ██╔══██╗██║██║ ██║
8
- ███████║██║██║ ██║
9
- ██╔══██║██║╚██╗ ██╔╝
10
- ██║ ██║██║ ╚████╔╝
11
- ╚═╝ ╚═╝╚═╝ ╚═══╝ by Ateriss
4
+ █████╗ ██╗ ██████╗ ██████╗ ██████╗ ███████╗██╗ ██╗██╗███████╗██╗ ██╗███████╗██████╗
5
+ ██╔══██╗██║ ██╔══██╗██╔══██╗ ██╔══██╗██╔════╝██║ ██║██║██╔════╝██║ ██║██╔════╝██╔══██╗
6
+ ███████║██║ ██████╔╝██████╔╝ ██████╔╝█████╗ ██║ ██║██║█████╗ ██║ █╗ ██║█████╗ ██████╔╝
7
+ ██╔══██║██║ ██╔═══╝ ██╔══██╗ ██╔══██╗██╔══╝ ╚██╗ ██╔╝██║██╔══╝ ██║███╗██║██╔══╝ ██╔══██╗
8
+ ██║ ██║██║ ██║ ██║ ██║ ██║ ██║███████╗ ╚████╔╝ ██║███████╗╚███╔███╔╝███████╗██║ ██║
9
+ ╚═╝ ╚═╝╚═╝ ╚═╝ ╚═╝ ╚═╝ ╚═╝ ╚═╝╚══════╝ ╚═══╝ ╚═╝╚══════╝ ╚══╝╚══╝ ╚══════╝╚═╝ ╚═╝
10
+
11
+ by Ateriss
12
12
  ```
13
13
 
14
14
  ---
15
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
+
16
40
  ## Table of Contents
17
41
 
18
42
  - [Requirements](#requirements)
@@ -45,7 +69,7 @@ A local-first, multi-agent CLI for reviewing GitHub pull requests using any supp
45
69
  ## Requirements
46
70
 
47
71
  - Node.js 18 or higher
48
- - A GitHub personal access token with `repo` scope
72
+ - A GitHub personal access token with `repo` scope (or `public_repo` for public repos)
49
73
  - An API key for at least one supported AI provider (see [AI Providers](#ai-providers))
50
74
 
51
75
  ---
@@ -53,17 +77,7 @@ A local-first, multi-agent CLI for reviewing GitHub pull requests using any supp
53
77
  ## Installation
54
78
 
55
79
  ```bash
56
- npm install -g aiv
57
- ```
58
-
59
- Or clone and build locally:
60
-
61
- ```bash
62
- git clone https://github.com/your-org/aiv-cli
63
- cd aiv-cli
64
- npm install
65
- npm run build
66
- npm link
80
+ npm install -g @ateriss_/aiv-cli
67
81
  ```
68
82
 
69
83
  ---
@@ -84,11 +98,16 @@ This creates:
84
98
  - `.aiv/context.md` — auto-generated project context
85
99
  - `.aiv/tree.json` — project file structure snapshot
86
100
 
87
- **2. Set your API key and GitHub token:**
101
+ **2. Set your API key and GitHub token as persistent environment variables:**
88
102
 
89
103
  ```bash
104
+ # macOS / Linux (add to ~/.bashrc or ~/.zshrc)
90
105
  export CLAUDE_API_KEY=sk-ant-...
91
106
  export GITHUB_TOKEN=ghp_...
107
+
108
+ # Windows (PowerShell — persists across sessions)
109
+ [System.Environment]::SetEnvironmentVariable("CLAUDE_API_KEY", "sk-ant-...", "User")
110
+ [System.Environment]::SetEnvironmentVariable("GITHUB_TOKEN", "ghp_...", "User")
92
111
  ```
93
112
 
94
113
  **3. (Optional) Let AI generate your context and rules:**
@@ -109,7 +128,7 @@ aiv prs
109
128
  aiv review 42
110
129
  ```
111
130
 
112
- After the report, aiv asks if you want to **approve or request changes** directly on GitHub.
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.
113
132
 
114
133
  ---
115
134
 
@@ -210,7 +229,7 @@ aiv review 42 --agent business architecture
210
229
  aiv review 42 --json # raw JSON, no interactive prompt
211
230
  ```
212
231
 
213
- After the report prints, aiv asks whether to **approve**, **request changes**, or **skip** and submits the decision directly to GitHub. If you approve, `context.md` and `tree.json` are refreshed automatically.
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.
214
233
 
215
234
  ---
216
235
 
@@ -230,7 +249,7 @@ aiv ctx generate --rules-only
230
249
  aiv ctx generate --force # overwrite without asking
231
250
  ```
232
251
 
233
- `generate` uses the configured AI provider (or `providers.agents.context` if set) to analyze the project structure and produce a `context.md` and `rules.yml` tailored to your stack. Run it after `init` or whenever a new AI agent type is added — edit the output only where needed.
252
+ `generate` uses the configured AI provider (or `providers.agents.context` if set) to analyze the project structure and produce a `context.md` and `rules.yml` tailored to your stack. Run it after `init` or whenever the project changes significantly — edit the output only where needed.
234
253
 
235
254
  ---
236
255
 
@@ -362,13 +381,15 @@ business_rules:
362
381
  - directDbWrite
363
382
  ```
364
383
 
384
+ The more specific your rules, the fewer false positives and the more actionable the findings.
385
+
365
386
  ---
366
387
 
367
388
  ### Context
368
389
 
369
390
  `.aiv/context.md` — project background that agents read before analyzing the diff.
370
391
 
371
- Auto-generated by `aiv init`, `aiv context refresh`, and `aiv context generate`. You can edit it freely — custom sections are preserved on the next refresh.
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.
372
393
 
373
394
  ```markdown
374
395
  ## Business Context
@@ -388,8 +409,6 @@ Services must not import from handlers.
388
409
  - src/payments/ — Stripe integration, never bypass PaymentGateway
389
410
  ```
390
411
 
391
- The richer this file, the more accurate the agent findings.
392
-
393
412
  ---
394
413
 
395
414
  ## GitHub Account Management
@@ -492,7 +511,7 @@ gemini:
492
511
 
493
512
  ### OpenAI-compatible providers
494
513
 
495
- Any provider that exposes an OpenAI-compatible API can be registered with one command — no code changes, no updates needed when new providers launch.
514
+ Any provider that exposes an OpenAI-compatible API can be registered with one command — no code changes needed when new providers launch.
496
515
 
497
516
  ```bash
498
517
  # Kimi (Moonshot AI)
@@ -530,12 +549,6 @@ aiv config add-provider ollama \
530
549
  --base-url http://localhost:11434/v1 \
531
550
  --api-key-env OLLAMA_API_KEY \
532
551
  --model llama3.2
533
-
534
- # Any future provider that adopts the OpenAI spec
535
- aiv config add-provider newprovider \
536
- --base-url https://api.newprovider.com/v1 \
537
- --api-key-env NEWPROVIDER_API_KEY \
538
- --model their-model-name
539
552
  ```
540
553
 
541
554
  Once registered, custom providers work exactly like built-ins:
@@ -554,7 +567,6 @@ aiv config add-provider kimi --model moonshot-v1-32k --force # update
554
567
  Each agent (and the context generator) can use a different provider or model:
555
568
 
556
569
  ```bash
557
- # Assign provider/model per agent
558
570
  aiv config set-agent-provider business claude/claude-sonnet-4-6
559
571
  aiv config set-agent-provider security openai/gpt-4.1
560
572
  aiv config set-agent-provider architecture gemini/gemini-2.0-flash
@@ -572,8 +584,6 @@ aiv config set-agent-provider business --clear
572
584
 
573
585
  Valid agent roles: `business`, `architecture`, `security`, `context`.
574
586
 
575
- The `context` role is used by `aiv context generate`. All other roles map to the review agents.
576
-
577
587
  ---
578
588
 
579
589
  ### Fallback chain
@@ -678,21 +688,44 @@ After every review in an interactive terminal, aiv asks:
678
688
  ? What would you like to do with this PR?
679
689
  ❯ ✔ Approve PR
680
690
  ⚑ Request Changes
691
+ 💬 Post as PR comment
681
692
  ────────────────────────────────────────
682
693
  ↩ Skip
683
694
  ```
684
695
 
685
- - **Approve** — submits an `APPROVE` review to GitHub, then auto-refreshes `context.md` and `tree.json`
686
- - **Request Changes** — submits a `REQUEST_CHANGES` review to GitHub
687
- - **Skip** — does nothing, exits cleanly
696
+ - **Approve** — submits an `APPROVE` review to GitHub, then asks if you want to merge:
697
+
698
+ ```
699
+ ? Merge this PR now? (y/N)
700
+
701
+ ? Select merge strategy:
702
+ ❯ Squash and merge
703
+ Merge commit
704
+ Rebase and merge
705
+ ```
706
+
707
+ After approving (with or without merge), `context.md` and `tree.json` are refreshed automatically.
688
708
 
689
- The context refresh on approval ensures agents have current information for future reviews of the same repo.
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.
711
+ - **Skip** — does nothing, exits cleanly.
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).
690
723
 
691
724
  ---
692
725
 
693
726
  ## Multi-language
694
727
 
695
- aiv supports English and Spanish. All output — errors, spinners, table headers, severity labels — follows the configured language.
728
+ aiv supports English and Spanish. All output — errors, spinners, table headers, severity labels, and AI agent responses — follows the configured language.
696
729
 
697
730
  ```bash
698
731
  aiv config set-lang es
@@ -721,14 +754,14 @@ AIV_LANG=es aiv prs # per-session override
721
754
  | `AIV_LANG` | No | Override display language (`en` or `es`) |
722
755
  | `LANG` | No | System locale (auto-detected by aiv) |
723
756
 
724
- For custom providers, the env var name is whatever you passed to `--api-key-env`:
757
+ For custom providers, the env var name is whatever you passed to `--api-key-env`.
725
758
 
726
- ```bash
727
- export KIMI_API_KEY=sk-...
728
- aiv config add-provider kimi --api-key-env KIMI_API_KEY ...
729
- ```
759
+ ### GitHub token permissions
730
760
 
731
- GitHub tokens require `repo` scope to read pull requests and diffs. To submit reviews (approve/request changes), the token also needs `pull_requests:write` scope.
761
+ | Scope | Required for |
762
+ |-------|-------------|
763
+ | `repo` (private repos) or `public_repo` | Reading PRs and diffs |
764
+ | `pull_requests: write` (fine-grained PAT) | Submitting reviews, posting comments, merging |
732
765
 
733
766
  ---
734
767
 
@@ -746,14 +779,18 @@ cd your-repo && aiv init
746
779
 
747
780
  ### `Missing env var: GITHUB_TOKEN (account: default)`
748
781
 
749
- 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:
750
783
 
751
784
  ```bash
752
- export GITHUB_TOKEN=ghp_...
753
- # or check which account/var is active:
754
785
  aiv config accounts
755
786
  ```
756
787
 
788
+ Then set it (once, permanently on Windows):
789
+
790
+ ```powershell
791
+ [System.Environment]::SetEnvironmentVariable("GITHUB_TOKEN", "ghp_...", "User")
792
+ ```
793
+
757
794
  ---
758
795
 
759
796
  ### `Missing env var: CLAUDE_API_KEY`
@@ -768,10 +805,8 @@ aiv config set-provider openai
768
805
 
769
806
  ### `Unknown provider: "xyz".`
770
807
 
771
- A provider name was used that isn't registered.
772
-
773
808
  ```bash
774
- aiv config list-providers # see what's configured
809
+ aiv config list-providers
775
810
  aiv config add-provider xyz --base-url <url> --api-key-env XYZ_API_KEY --model <model>
776
811
  ```
777
812
 
@@ -779,8 +814,6 @@ aiv config add-provider xyz --base-url <url> --api-key-env XYZ_API_KEY --model <
779
814
 
780
815
  ### `Could not detect GitHub owner/repo.`
781
816
 
782
- The git remote is missing or not a GitHub URL.
783
-
784
817
  ```bash
785
818
  aiv prs --owner myorg --repo myrepo
786
819
  # or set permanently:
@@ -789,21 +822,12 @@ aiv config set-repo myorg myrepo
789
822
 
790
823
  ---
791
824
 
792
- ### `Account "xyz" not found.`
793
-
794
- ```bash
795
- aiv config accounts
796
- aiv config add-account xyz --token-env MY_TOKEN
797
- ```
798
-
799
- ---
800
-
801
825
  ### `Failed to fetch PR: ...`
802
826
 
803
- - Token lacks `repo` scope — regenerate
804
- - PR number doesn't exist
805
- - GitHub rate limit — wait or switch token
806
- - Wrong owner/repo — check with `aiv config show`
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`
807
831
 
808
832
  ---
809
833
 
@@ -811,10 +835,9 @@ aiv config add-account xyz --token-env MY_TOKEN
811
835
 
812
836
  - API key invalid or expired
813
837
  - Model quota exceeded — configure a [fallback chain](#fallback-chain)
814
- - Diff too large — reduce `max_tokens`:
838
+ - Diff too large — reduce `max_tokens` in `.aiv/config.yml`:
815
839
 
816
840
  ```yaml
817
- # .aiv/config.yml
818
841
  review:
819
842
  max_tokens: 10000
820
843
  ```
@@ -831,26 +854,30 @@ Right after `aiv init`, run:
831
854
  aiv context generate
832
855
  ```
833
856
 
834
- This gives you a ready-to-edit `context.md` and `rules.yml` based on what the AI infers from your project. Tune what it gets wrong rather than writing from scratch.
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.
835
858
 
836
- ### Keep rules.yml current
859
+ ### Write specific rules
837
860
 
838
- Add a rule whenever your team agrees on a pattern reviews should catch:
861
+ Generic rules produce generic findings. The more specific `rules.yml` is, the more precise the business agent becomes:
839
862
 
840
863
  ```yaml
841
864
  business_rules:
842
865
  orders:
843
- required_calls: [validateInventory]
844
- forbidden_patterns: [skipFraudCheck]
866
+ required_calls: [validateInventory, reserveStock]
867
+ forbidden_patterns: [skipFraudCheck, directInventoryWrite]
845
868
  ```
846
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
+
847
874
  ### Refresh context after structural changes
848
875
 
849
876
  ```bash
850
877
  aiv context refresh
851
878
  ```
852
879
 
853
- Run after merging large refactors, adding modules, or changing the project layout.
880
+ Run after merging large refactors, adding new modules, or reorganizing the project layout.
854
881
 
855
882
  ### Use a fallback chain for reliability
856
883
 
@@ -860,20 +887,20 @@ aiv config set-fallback openai gemini
860
887
 
861
888
  If your primary provider is rate-limited mid-review, aiv switches automatically without losing the run.
862
889
 
863
- ### Match model to task with per-agent assignment
890
+ ### Match model to task
864
891
 
865
- Use a fast/cheap model for straightforward agents and a powerful one for the critical ones:
892
+ Use a fast/cheap model for straightforward agents and a stronger one for the most critical:
866
893
 
867
894
  ```bash
868
895
  aiv config set-agent-provider business claude/claude-haiku-4-5
869
896
  aiv config set-agent-provider architecture claude/claude-haiku-4-5
870
- aiv config set-agent-provider security claude/claude-sonnet-4-6 # strongest model here
897
+ aiv config set-agent-provider security claude/claude-sonnet-4-6
871
898
  ```
872
899
 
873
900
  ### Use `--agent` to narrow focus
874
901
 
875
902
  ```bash
876
- aiv review 101 --agent security # dependency bump
903
+ aiv review 101 --agent security # dependency bump — only security matters
877
904
  aiv review 202 --agent business architecture # domain change
878
905
  ```
879
906
 
@@ -881,14 +908,14 @@ Fewer agents = faster, cheaper, more focused output.
881
908
 
882
909
  ### Commit `.aiv/` to the repository
883
910
 
884
- 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`:
885
912
 
886
913
  ```
887
914
  # .gitignore
888
915
  .aiv/tree.json
889
916
  ```
890
917
 
891
- `aiv init` adds this automatically.
918
+ `aiv init` adds this entry automatically.
892
919
 
893
920
  ### CI integration with `--json`
894
921
 
@@ -906,7 +933,7 @@ fi
906
933
  - Not a replacement for static analysis (ESLint, SonarQube)
907
934
  - Not a style checker
908
935
 
909
- Its value is **semantic understanding**: catching business rule violations, architectural drift, and security risks that automated tools miss because they require project context to understand.
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.
910
937
 
911
938
  ---
912
939
 
@@ -918,7 +945,7 @@ src/
918
945
  cli/
919
946
  commands/ — init, prs, review, config, context, agents
920
947
  banner.ts — ASCII welcome banner
921
- renderer.ts — review result pretty-printer
948
+ renderer.ts — terminal renderer + GitHub comment builder
922
949
  selector.ts — interactive PR/action picker (inquirer)
923
950
  config/ — two-level config load/save/merge
924
951
  context/