@ateriss_/aiv-cli 0.1.0 → 1.0.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.md +329 -324
- package/dist/index.js +50 -48
- package/package.json +1 -1
- package/src/agents/base.ts +6 -1
- package/src/cli/commands/review.ts +13 -1
- package/src/cli/selector.ts +29 -0
- package/src/git/github.ts +16 -0
- package/src/i18n/en.ts +8 -0
- package/src/i18n/es.ts +8 -0
package/README.md
CHANGED
|
@@ -3,14 +3,14 @@
|
|
|
3
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
4
|
|
|
5
5
|
```
|
|
6
|
-
█████╗ ██╗ ██████╗ ██████╗ ██████╗ ███████╗██╗ ██╗██╗███████╗██╗ ██╗███████╗██████╗
|
|
6
|
+
█████╗ ██╗ ██████╗ ██████╗ ██████╗ ███████╗██╗ ██╗██╗███████╗██╗ ██╗███████╗██████╗
|
|
7
7
|
██╔══██╗██║ ██╔══██╗██╔══██╗ ██╔══██╗██╔════╝██║ ██║██║██╔════╝██║ ██║██╔════╝██╔══██╗
|
|
8
8
|
███████║██║ ██████╔╝██████╔╝ ██████╔╝█████╗ ██║ ██║██║█████╗ ██║ █╗ ██║█████╗ ██████╔╝
|
|
9
9
|
██╔══██║██║ ██╔═══╝ ██╔══██╗ ██╔══██╗██╔══╝ ╚██╗ ██╔╝██║██╔══╝ ██║███╗██║██╔══╝ ██╔══██╗
|
|
10
10
|
██║ ██║██║ ██║ ██║ ██║ ██║ ██║███████╗ ╚████╔╝ ██║███████╗╚███╔███╔╝███████╗██║ ██║
|
|
11
|
-
╚═╝ ╚═╝╚═╝ ╚═╝ ╚═╝ ╚═╝ ╚═╝ ╚═╝╚══════╝ ╚═══╝ ╚═╝╚══════╝ ╚══╝╚══╝ ╚══════╝╚═╝
|
|
12
|
-
|
|
13
|
-
|
|
11
|
+
╚═╝ ╚═╝╚═╝ ╚═╝ ╚═╝ ╚═╝ ╚═╝ ╚═╝╚══════╝ ╚═══╝ ╚═╝╚══════╝ ╚══╝╚══╝ ╚══════╝╚═╝ ╚═╝`;
|
|
12
|
+
|
|
13
|
+
by Ateriss
|
|
14
14
|
```
|
|
15
15
|
|
|
16
16
|
---
|
|
@@ -22,13 +22,21 @@ A local-first, multi-agent CLI for reviewing GitHub pull requests using any supp
|
|
|
22
22
|
- [Quick Start](#quick-start)
|
|
23
23
|
- [Commands Reference](#commands-reference)
|
|
24
24
|
- [Configuration](#configuration)
|
|
25
|
-
- [Global Config](#global-config
|
|
26
|
-
- [Repo Config](#repo-config
|
|
27
|
-
- [Rules](#rules
|
|
28
|
-
- [Context](#context
|
|
25
|
+
- [Global Config](#global-config)
|
|
26
|
+
- [Repo Config](#repo-config)
|
|
27
|
+
- [Rules](#rules)
|
|
28
|
+
- [Context](#context)
|
|
29
29
|
- [GitHub Account Management](#github-account-management)
|
|
30
30
|
- [AI Providers](#ai-providers)
|
|
31
|
+
- [Built-in: Claude](#claude-default)
|
|
32
|
+
- [Built-in: OpenAI](#openai)
|
|
33
|
+
- [Built-in: Gemini](#google-gemini)
|
|
34
|
+
- [OpenAI-compatible (custom)](#openai-compatible-providers)
|
|
35
|
+
- [Per-agent assignment](#per-agent-provider-assignment)
|
|
36
|
+
- [Fallback chain](#fallback-chain)
|
|
37
|
+
- [Mock](#mock-offline-testing)
|
|
31
38
|
- [Review Output](#review-output)
|
|
39
|
+
- [Post-review Actions](#post-review-actions)
|
|
32
40
|
- [Multi-language](#multi-language)
|
|
33
41
|
- [Environment Variables](#environment-variables)
|
|
34
42
|
- [Error Reference](#error-reference)
|
|
@@ -39,7 +47,7 @@ A local-first, multi-agent CLI for reviewing GitHub pull requests using any supp
|
|
|
39
47
|
## Requirements
|
|
40
48
|
|
|
41
49
|
- Node.js 18 or higher
|
|
42
|
-
- A GitHub personal access token with `repo` scope
|
|
50
|
+
- A GitHub personal access token with `repo` scope (or `public_repo` for public repos)
|
|
43
51
|
- An API key for at least one supported AI provider (see [AI Providers](#ai-providers))
|
|
44
52
|
|
|
45
53
|
---
|
|
@@ -47,17 +55,7 @@ A local-first, multi-agent CLI for reviewing GitHub pull requests using any supp
|
|
|
47
55
|
## Installation
|
|
48
56
|
|
|
49
57
|
```bash
|
|
50
|
-
npm install -g aiv
|
|
51
|
-
```
|
|
52
|
-
|
|
53
|
-
Or clone and build locally:
|
|
54
|
-
|
|
55
|
-
```bash
|
|
56
|
-
git clone https://github.com/your-org/aiv-cli
|
|
57
|
-
cd aiv-cli
|
|
58
|
-
npm install
|
|
59
|
-
npm run build
|
|
60
|
-
npm link
|
|
58
|
+
npm install -g @ateriss_/aiv-cli
|
|
61
59
|
```
|
|
62
60
|
|
|
63
61
|
---
|
|
@@ -72,32 +70,43 @@ aiv init
|
|
|
72
70
|
```
|
|
73
71
|
|
|
74
72
|
This creates:
|
|
75
|
-
- `~/.aiv/config.yml` — global config (AI
|
|
73
|
+
- `~/.aiv/config.yml` — global config (AI providers, GitHub accounts)
|
|
76
74
|
- `.aiv/config.yml` — repo config (owner, repo, account override)
|
|
77
75
|
- `.aiv/rules.yml` — custom review rules for agents
|
|
78
76
|
- `.aiv/context.md` — auto-generated project context
|
|
79
77
|
- `.aiv/tree.json` — project file structure snapshot
|
|
80
78
|
|
|
81
|
-
**2. Set your API key and GitHub token:**
|
|
79
|
+
**2. Set your API key and GitHub token as persistent environment variables:**
|
|
82
80
|
|
|
83
81
|
```bash
|
|
82
|
+
# macOS / Linux (add to ~/.bashrc or ~/.zshrc)
|
|
84
83
|
export CLAUDE_API_KEY=sk-ant-...
|
|
85
84
|
export GITHUB_TOKEN=ghp_...
|
|
85
|
+
|
|
86
|
+
# Windows (PowerShell — persists across sessions)
|
|
87
|
+
[System.Environment]::SetEnvironmentVariable("CLAUDE_API_KEY", "sk-ant-...", "User")
|
|
88
|
+
[System.Environment]::SetEnvironmentVariable("GITHUB_TOKEN", "ghp_...", "User")
|
|
89
|
+
```
|
|
90
|
+
|
|
91
|
+
**3. (Optional) Let AI generate your context and rules:**
|
|
92
|
+
|
|
93
|
+
```bash
|
|
94
|
+
aiv context generate
|
|
86
95
|
```
|
|
87
96
|
|
|
88
|
-
**
|
|
97
|
+
**4. List open pull requests:**
|
|
89
98
|
|
|
90
99
|
```bash
|
|
91
100
|
aiv prs
|
|
92
101
|
```
|
|
93
102
|
|
|
94
|
-
**
|
|
103
|
+
**5. Review a PR:**
|
|
95
104
|
|
|
96
105
|
```bash
|
|
97
106
|
aiv review 42
|
|
98
107
|
```
|
|
99
108
|
|
|
100
|
-
|
|
109
|
+
After the report, aiv asks if you want to **approve**, **request changes**, or **merge** directly on GitHub.
|
|
101
110
|
|
|
102
111
|
---
|
|
103
112
|
|
|
@@ -105,150 +114,135 @@ That's it. The three agents run in parallel and print a full report.
|
|
|
105
114
|
|
|
106
115
|
Every command has a short alias. Long and short forms are identical.
|
|
107
116
|
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
|
111
|
-
|
|
112
|
-
| `aiv
|
|
113
|
-
| `aiv
|
|
114
|
-
| `aiv
|
|
115
|
-
| `aiv
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
|
120
|
-
|
|
121
|
-
| `aiv
|
|
122
|
-
| `aiv
|
|
123
|
-
| `aiv
|
|
124
|
-
|
|
125
|
-
|
|
117
|
+
### Core
|
|
118
|
+
|
|
119
|
+
| Long form | Short | Description |
|
|
120
|
+
|-----------|-------|-------------|
|
|
121
|
+
| `aiv init` | `aiv i` | Initialize aiv globally and in the current repo |
|
|
122
|
+
| `aiv prs` | `aiv p` | List open PRs, then optionally review one |
|
|
123
|
+
| `aiv review [pr-number]` | `aiv r` | Review a PR or pick interactively |
|
|
124
|
+
| `aiv agents` | `aiv a` | List available agents and their focus areas |
|
|
125
|
+
|
|
126
|
+
### Context
|
|
127
|
+
|
|
128
|
+
| Long form | Short | Description |
|
|
129
|
+
|-----------|-------|-------------|
|
|
130
|
+
| `aiv context refresh` | `aiv ctx refresh` | Rebuild `context.md` and `tree.json` from the codebase |
|
|
131
|
+
| `aiv context show` | `aiv ctx show` | Print current `context.md` |
|
|
132
|
+
| `aiv context generate` | `aiv ctx generate` | Use AI to generate `context.md` and `rules.yml` |
|
|
133
|
+
|
|
134
|
+
### Config — general
|
|
135
|
+
|
|
136
|
+
| Long form | Short | Description |
|
|
137
|
+
|-----------|-------|-------------|
|
|
138
|
+
| `aiv config show` | `aiv cf show` | Show global and repo config files |
|
|
139
|
+
| `aiv config set-provider <name>` | `aiv cf set-provider` | Set default AI provider |
|
|
140
|
+
| `aiv config set-repo <owner> <repo>` | `aiv cf set-repo` | Set GitHub owner/repo in repo config |
|
|
141
|
+
| `aiv config set-lang <lang>` | `aiv cf set-lang` | Change display language (`en` / `es`) |
|
|
142
|
+
| `aiv config rules` | `aiv cf rules` | Print `rules.yml` |
|
|
143
|
+
|
|
144
|
+
### Config — providers
|
|
145
|
+
|
|
146
|
+
| Long form | Description |
|
|
147
|
+
|-----------|-------------|
|
|
148
|
+
| `aiv config add-provider <name>` | Add or update a provider (built-in or custom OpenAI-compatible) |
|
|
149
|
+
| `aiv config remove-provider <name>` | Remove a custom provider |
|
|
150
|
+
| `aiv config list-providers` | List all configured providers and their status |
|
|
151
|
+
| `aiv config set-agent-provider <agent> [spec]` | Assign a specific provider/model to one agent |
|
|
152
|
+
| `aiv config set-fallback [providers...]` | Set ordered fallback chain for quota/rate errors |
|
|
153
|
+
| `aiv config show-agents` | Show per-agent provider assignments and fallback chain |
|
|
154
|
+
|
|
155
|
+
### Config — GitHub accounts
|
|
156
|
+
|
|
157
|
+
| Long form | Description |
|
|
158
|
+
|-----------|-------------|
|
|
159
|
+
| `aiv config accounts` | List GitHub accounts |
|
|
160
|
+
| `aiv config add-account <name>` | Add a GitHub account |
|
|
161
|
+
| `aiv config remove-account <name>` | Remove a GitHub account |
|
|
162
|
+
| `aiv config default-account <name>` | Set global default account |
|
|
163
|
+
| `aiv config use-account <name>` | Use a specific account for this repo |
|
|
126
164
|
|
|
127
165
|
---
|
|
128
166
|
|
|
129
167
|
### `aiv init`
|
|
130
168
|
|
|
131
|
-
Initializes aiv globally and in the current repository.
|
|
132
|
-
|
|
133
169
|
```bash
|
|
134
170
|
aiv init
|
|
135
171
|
aiv i
|
|
136
172
|
```
|
|
137
173
|
|
|
138
|
-
Safe to run
|
|
174
|
+
Safe to re-run — if `~/.aiv/config.yml` already exists it is preserved. Re-running inside a repo always rebuilds `context.md` and `tree.json`.
|
|
139
175
|
|
|
140
176
|
---
|
|
141
177
|
|
|
142
178
|
### `aiv prs`
|
|
143
179
|
|
|
144
|
-
Fetches
|
|
180
|
+
Fetches open PRs in a table, then launches an interactive selector.
|
|
145
181
|
|
|
146
182
|
```bash
|
|
147
183
|
aiv prs
|
|
148
184
|
aiv p
|
|
149
185
|
|
|
150
|
-
# Limit results
|
|
151
186
|
aiv prs --limit 10
|
|
152
|
-
|
|
153
|
-
# Override repo auto-detection
|
|
154
187
|
aiv prs --owner myorg --repo myrepo
|
|
155
|
-
|
|
156
|
-
# List only, skip interactive selector
|
|
157
|
-
aiv prs --no-select
|
|
188
|
+
aiv prs --no-select # list only, skip selector
|
|
158
189
|
```
|
|
159
190
|
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
**Repo auto-detection:** aiv reads `git remote get-url origin` to detect the GitHub owner and repo. If the remote is not a GitHub URL or is missing, use `--owner`/`--repo` flags or configure them in `.aiv/config.yml`.
|
|
191
|
+
**Repo auto-detection:** reads `git remote get-url origin`. If it fails, pass `--owner`/`--repo` or set them with `aiv config set-repo`.
|
|
163
192
|
|
|
164
193
|
---
|
|
165
194
|
|
|
166
195
|
### `aiv review`
|
|
167
196
|
|
|
168
|
-
Reviews a pull request.
|
|
197
|
+
Reviews a pull request. Omit the number to pick interactively.
|
|
169
198
|
|
|
170
199
|
```bash
|
|
171
|
-
# Review by number
|
|
172
200
|
aiv review 42
|
|
173
201
|
aiv r 42
|
|
174
202
|
|
|
175
|
-
#
|
|
176
|
-
aiv review
|
|
177
|
-
aiv r
|
|
178
|
-
|
|
179
|
-
# Override repo
|
|
203
|
+
aiv review # interactive selector
|
|
180
204
|
aiv review 42 --owner myorg --repo myrepo
|
|
181
|
-
|
|
182
|
-
# Run specific agents only
|
|
183
205
|
aiv review 42 --agent security
|
|
184
206
|
aiv review 42 --agent business architecture
|
|
185
|
-
|
|
186
|
-
# Output raw JSON (useful for scripting and CI)
|
|
187
|
-
aiv review 42 --json
|
|
207
|
+
aiv review 42 --json # raw JSON, no interactive prompt
|
|
188
208
|
```
|
|
189
209
|
|
|
190
|
-
|
|
210
|
+
After the report prints, aiv asks whether to **approve**, **request changes**, or **skip** — and submits the decision directly to GitHub. If you approve, you can optionally merge the PR right away and choose the merge strategy. `context.md` and `tree.json` are always refreshed after an approval.
|
|
191
211
|
|
|
192
212
|
---
|
|
193
213
|
|
|
194
214
|
### `aiv context`
|
|
195
215
|
|
|
196
|
-
Manages the project context used by agents during reviews.
|
|
197
|
-
|
|
198
216
|
```bash
|
|
199
|
-
|
|
200
|
-
aiv context refresh
|
|
217
|
+
aiv context refresh # rebuild from codebase (static analysis)
|
|
201
218
|
aiv ctx refresh
|
|
202
219
|
|
|
203
|
-
|
|
204
|
-
aiv context show
|
|
220
|
+
aiv context show # print context.md
|
|
205
221
|
aiv ctx show
|
|
206
|
-
```
|
|
207
|
-
|
|
208
|
-
Run `context refresh` after major structural changes to the project (new modules, new dependencies, large refactors) so agents have accurate background information.
|
|
209
|
-
|
|
210
|
-
---
|
|
211
|
-
|
|
212
|
-
### `aiv config`
|
|
213
|
-
|
|
214
|
-
All configuration subcommands. Running `aiv config` or `aiv cf` alone prints help.
|
|
215
|
-
|
|
216
|
-
```bash
|
|
217
|
-
# Show global and repo config files
|
|
218
|
-
aiv config show
|
|
219
|
-
aiv cf show
|
|
220
|
-
|
|
221
|
-
# Switch AI provider
|
|
222
|
-
aiv config set-provider openai
|
|
223
|
-
aiv cf set-provider claude
|
|
224
|
-
|
|
225
|
-
# Set repo owner/repo explicitly
|
|
226
|
-
aiv config set-repo myorg myrepo
|
|
227
|
-
|
|
228
|
-
# Change display language
|
|
229
|
-
aiv config set-lang es
|
|
230
|
-
aiv config set-lang en
|
|
231
222
|
|
|
232
|
-
#
|
|
233
|
-
aiv
|
|
223
|
+
aiv context generate # AI-powered generation
|
|
224
|
+
aiv ctx generate
|
|
225
|
+
aiv ctx generate --context-only
|
|
226
|
+
aiv ctx generate --rules-only
|
|
227
|
+
aiv ctx generate --force # overwrite without asking
|
|
234
228
|
```
|
|
235
229
|
|
|
230
|
+
`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.
|
|
231
|
+
|
|
236
232
|
---
|
|
237
233
|
|
|
238
234
|
### `aiv agents`
|
|
239
235
|
|
|
240
|
-
Lists all available agents with their description and focus areas.
|
|
241
|
-
|
|
242
236
|
```bash
|
|
243
237
|
aiv agents
|
|
244
238
|
aiv a
|
|
245
239
|
```
|
|
246
240
|
|
|
247
|
-
| Agent
|
|
248
|
-
|
|
249
|
-
| business
|
|
241
|
+
| Agent | Focus areas |
|
|
242
|
+
|-------|-------------|
|
|
243
|
+
| business | Business logic, domain invariants, rule violations, functional regressions |
|
|
250
244
|
| architecture | Layer violations, coupling, SRP, dependency direction, abstraction quality |
|
|
251
|
-
| security
|
|
245
|
+
| security | Auth bypass, injection, data leakage, OWASP Top 10, sensitive data handling |
|
|
252
246
|
|
|
253
247
|
---
|
|
254
248
|
|
|
@@ -256,36 +250,58 @@ aiv a
|
|
|
256
250
|
|
|
257
251
|
aiv uses a two-level configuration system:
|
|
258
252
|
|
|
259
|
-
| File
|
|
260
|
-
|
|
261
|
-
| `~/.aiv/config.yml`
|
|
262
|
-
| `.aiv/config.yml`
|
|
253
|
+
| File | Scope | Purpose |
|
|
254
|
+
|------|-------|---------|
|
|
255
|
+
| `~/.aiv/config.yml` | Global | AI providers, GitHub accounts, defaults |
|
|
256
|
+
| `.aiv/config.yml` | Repo | Owner/repo override, account override, token limits |
|
|
263
257
|
|
|
264
|
-
Repo
|
|
258
|
+
Repo settings always override global defaults.
|
|
265
259
|
|
|
266
260
|
---
|
|
267
261
|
|
|
268
|
-
### Global Config
|
|
262
|
+
### Global Config
|
|
269
263
|
|
|
270
|
-
|
|
264
|
+
`~/.aiv/config.yml` — created by `aiv init`, shared across all repos.
|
|
271
265
|
|
|
272
266
|
```yaml
|
|
273
267
|
lang: en # 'en' or 'es'
|
|
274
268
|
|
|
275
269
|
providers:
|
|
276
|
-
default: claude #
|
|
277
|
-
|
|
270
|
+
default: claude # active provider
|
|
271
|
+
fallback: [openai, gemini] # tried in order on quota/rate errors
|
|
272
|
+
agents: # per-agent overrides (provider or provider/model)
|
|
273
|
+
business: claude/claude-sonnet-4-6
|
|
274
|
+
architecture: gemini/gemini-2.0-flash
|
|
275
|
+
security: openai/gpt-4.1
|
|
276
|
+
context: claude/claude-sonnet-4-6
|
|
277
|
+
|
|
278
|
+
# Built-in providers
|
|
278
279
|
claude:
|
|
279
280
|
model: claude-sonnet-4-6
|
|
280
|
-
api_key_env: CLAUDE_API_KEY
|
|
281
|
+
api_key_env: CLAUDE_API_KEY
|
|
281
282
|
|
|
282
283
|
openai:
|
|
283
284
|
model: gpt-4.1
|
|
284
|
-
api_key_env: OPENAI_API_KEY
|
|
285
|
+
api_key_env: OPENAI_API_KEY
|
|
286
|
+
|
|
287
|
+
gemini:
|
|
288
|
+
model: gemini-2.0-flash
|
|
289
|
+
api_key_env: GEMINI_API_KEY
|
|
290
|
+
|
|
291
|
+
# Custom OpenAI-compatible providers
|
|
292
|
+
custom_providers:
|
|
293
|
+
kimi:
|
|
294
|
+
base_url: https://api.moonshot.cn/v1
|
|
295
|
+
api_key_env: KIMI_API_KEY
|
|
296
|
+
model: moonshot-v1-8k
|
|
297
|
+
groq:
|
|
298
|
+
base_url: https://api.groq.com/openai/v1
|
|
299
|
+
api_key_env: GROQ_API_KEY
|
|
300
|
+
model: llama-3.3-70b-versatile
|
|
285
301
|
|
|
286
302
|
review:
|
|
287
|
-
max_tokens: 20000
|
|
288
|
-
max_findings: 20
|
|
303
|
+
max_tokens: 20000
|
|
304
|
+
max_findings: 20
|
|
289
305
|
|
|
290
306
|
github:
|
|
291
307
|
default_account: personal
|
|
@@ -302,9 +318,9 @@ github:
|
|
|
302
318
|
|
|
303
319
|
---
|
|
304
320
|
|
|
305
|
-
### Repo Config
|
|
321
|
+
### Repo Config
|
|
306
322
|
|
|
307
|
-
|
|
323
|
+
`.aiv/config.yml` — created per repository by `aiv init`.
|
|
308
324
|
|
|
309
325
|
```yaml
|
|
310
326
|
github:
|
|
@@ -317,13 +333,11 @@ review:
|
|
|
317
333
|
max_findings: 30
|
|
318
334
|
```
|
|
319
335
|
|
|
320
|
-
Leave any field out to inherit from global config. The `account` field references a named account defined in `~/.aiv/config.yml`.
|
|
321
|
-
|
|
322
336
|
---
|
|
323
337
|
|
|
324
|
-
### Rules
|
|
338
|
+
### Rules
|
|
325
339
|
|
|
326
|
-
|
|
340
|
+
`.aiv/rules.yml` — custom review rules passed to every agent on every review.
|
|
327
341
|
|
|
328
342
|
```yaml
|
|
329
343
|
sensitive_modules:
|
|
@@ -345,25 +359,25 @@ business_rules:
|
|
|
345
359
|
- directDbWrite
|
|
346
360
|
```
|
|
347
361
|
|
|
348
|
-
Rules are passed verbatim to every agent on every review. The business and security agents use them to flag violations explicitly.
|
|
349
|
-
|
|
350
362
|
---
|
|
351
363
|
|
|
352
|
-
### Context
|
|
364
|
+
### Context
|
|
365
|
+
|
|
366
|
+
`.aiv/context.md` — project background that agents read before analyzing the diff.
|
|
353
367
|
|
|
354
|
-
Auto-generated by `aiv init
|
|
368
|
+
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.
|
|
355
369
|
|
|
356
370
|
```markdown
|
|
357
371
|
## Business Context
|
|
358
372
|
|
|
359
|
-
|
|
360
|
-
All changes
|
|
361
|
-
|
|
373
|
+
E-commerce platform handling real-money transactions.
|
|
374
|
+
All changes in `src/payments/` must include an audit log entry.
|
|
375
|
+
`UserBalance` must never be modified outside the `billing` module.
|
|
362
376
|
|
|
363
377
|
## Architecture
|
|
364
378
|
|
|
365
379
|
Three-layer: HTTP handlers → service layer → repositories.
|
|
366
|
-
|
|
380
|
+
Services must not import from handlers.
|
|
367
381
|
|
|
368
382
|
## Sensitive Zones
|
|
369
383
|
|
|
@@ -377,63 +391,32 @@ The richer this file, the more accurate the agent findings.
|
|
|
377
391
|
|
|
378
392
|
## GitHub Account Management
|
|
379
393
|
|
|
380
|
-
aiv supports multiple GitHub accounts (personal, work, CI bot) stored globally and activated per repo.
|
|
381
|
-
|
|
382
394
|
### Add accounts
|
|
383
395
|
|
|
384
396
|
```bash
|
|
385
|
-
# Minimum — just the env var name
|
|
386
397
|
aiv config add-account personal --token-env GITHUB_TOKEN
|
|
387
|
-
|
|
388
|
-
# With optional metadata
|
|
389
398
|
aiv config add-account work \
|
|
390
399
|
--token-env GITHUB_TOKEN_WORK \
|
|
391
400
|
--username alice-corp \
|
|
392
|
-
--description "Work GitHub
|
|
393
|
-
|
|
394
|
-
# Overwrite an existing account
|
|
395
|
-
aiv config add-account work --token-env NEW_VAR --force
|
|
396
|
-
```
|
|
397
|
-
|
|
398
|
-
### List accounts
|
|
399
|
-
|
|
400
|
-
```bash
|
|
401
|
-
aiv config accounts
|
|
402
|
-
```
|
|
403
|
-
|
|
404
|
-
Shows all configured accounts, their token env vars, which ones are set, and which is the global default.
|
|
405
|
-
|
|
406
|
-
### Set global default
|
|
407
|
-
|
|
408
|
-
```bash
|
|
409
|
-
aiv config default-account work
|
|
410
|
-
```
|
|
411
|
-
|
|
412
|
-
All repos without an explicit account override will use this account.
|
|
413
|
-
|
|
414
|
-
### Use a specific account for one repo
|
|
415
|
-
|
|
416
|
-
```bash
|
|
417
|
-
cd my-work-repo
|
|
418
|
-
aiv config use-account work
|
|
401
|
+
--description "Work GitHub"
|
|
402
|
+
aiv config add-account work --token-env NEW_VAR --force # overwrite
|
|
419
403
|
```
|
|
420
404
|
|
|
421
|
-
|
|
422
|
-
|
|
423
|
-
### Remove an account
|
|
405
|
+
### Manage accounts
|
|
424
406
|
|
|
425
407
|
```bash
|
|
408
|
+
aiv config accounts # list all accounts + token status
|
|
409
|
+
aiv config default-account work # set global default
|
|
410
|
+
aiv config use-account work # use this account for current repo
|
|
426
411
|
aiv config remove-account old-account
|
|
427
412
|
```
|
|
428
413
|
|
|
429
414
|
### Account resolution order
|
|
430
415
|
|
|
431
|
-
|
|
432
|
-
|
|
433
|
-
1. `github.account` in `.aiv/config.yml` (repo-level override)
|
|
416
|
+
1. `github.account` in `.aiv/config.yml`
|
|
434
417
|
2. `github.default_account` in `~/.aiv/config.yml`
|
|
435
|
-
3. First account
|
|
436
|
-
4.
|
|
418
|
+
3. First account in `~/.aiv/config.yml`
|
|
419
|
+
4. `GITHUB_TOKEN` env var directly
|
|
437
420
|
|
|
438
421
|
---
|
|
439
422
|
|
|
@@ -443,9 +426,9 @@ aiv supports three kinds of providers:
|
|
|
443
426
|
|
|
444
427
|
| Type | Examples | Notes |
|
|
445
428
|
|------|----------|-------|
|
|
446
|
-
| **Built-in** | Claude, OpenAI, Gemini | Native adapters,
|
|
447
|
-
| **OpenAI-compatible** | Kimi, Groq, Mistral, DeepSeek, Ollama,
|
|
448
|
-
| **Mock** | — | Deterministic offline responses
|
|
429
|
+
| **Built-in** | Claude, OpenAI, Gemini | Native adapters, no extra setup |
|
|
430
|
+
| **OpenAI-compatible** | Kimi, Groq, Mistral, DeepSeek, Ollama, … | Any provider with a compatible endpoint |
|
|
431
|
+
| **Mock** | — | Deterministic offline responses |
|
|
449
432
|
|
|
450
433
|
---
|
|
451
434
|
|
|
@@ -456,7 +439,7 @@ export CLAUDE_API_KEY=sk-ant-...
|
|
|
456
439
|
aiv config set-provider claude
|
|
457
440
|
```
|
|
458
441
|
|
|
459
|
-
Update model or key env
|
|
442
|
+
Update model or key env:
|
|
460
443
|
|
|
461
444
|
```bash
|
|
462
445
|
aiv config add-provider claude --model claude-opus-4-7
|
|
@@ -464,7 +447,6 @@ aiv config add-provider claude --api-key-env MY_CLAUDE_KEY
|
|
|
464
447
|
```
|
|
465
448
|
|
|
466
449
|
```yaml
|
|
467
|
-
# ~/.aiv/config.yml
|
|
468
450
|
claude:
|
|
469
451
|
model: claude-sonnet-4-6
|
|
470
452
|
api_key_env: CLAUDE_API_KEY
|
|
@@ -489,17 +471,12 @@ openai:
|
|
|
489
471
|
|
|
490
472
|
### Google Gemini
|
|
491
473
|
|
|
492
|
-
Gemini uses a dedicated REST adapter
|
|
474
|
+
Gemini uses a dedicated REST adapter — no extra SDK or dependency required.
|
|
493
475
|
|
|
494
476
|
```bash
|
|
495
477
|
export GEMINI_API_KEY=AIza...
|
|
496
478
|
aiv config set-provider gemini
|
|
497
|
-
|
|
498
|
-
|
|
499
|
-
Update model:
|
|
500
|
-
|
|
501
|
-
```bash
|
|
502
|
-
aiv config add-provider gemini --model gemini-2.0-flash-exp
|
|
479
|
+
aiv config add-provider gemini --model gemini-2.0-flash-exp # change model
|
|
503
480
|
```
|
|
504
481
|
|
|
505
482
|
```yaml
|
|
@@ -510,27 +487,24 @@ gemini:
|
|
|
510
487
|
|
|
511
488
|
---
|
|
512
489
|
|
|
513
|
-
### OpenAI-compatible providers
|
|
490
|
+
### OpenAI-compatible providers
|
|
514
491
|
|
|
515
|
-
Any provider that exposes an OpenAI-compatible API can be registered with one command
|
|
492
|
+
Any provider that exposes an OpenAI-compatible API can be registered with one command — no code changes, no updates needed when new providers launch.
|
|
516
493
|
|
|
517
494
|
```bash
|
|
518
495
|
# Kimi (Moonshot AI)
|
|
519
|
-
export KIMI_API_KEY=sk-...
|
|
520
496
|
aiv config add-provider kimi \
|
|
521
497
|
--base-url https://api.moonshot.cn/v1 \
|
|
522
498
|
--api-key-env KIMI_API_KEY \
|
|
523
499
|
--model moonshot-v1-8k
|
|
524
500
|
|
|
525
501
|
# Groq
|
|
526
|
-
export GROQ_API_KEY=gsk_...
|
|
527
502
|
aiv config add-provider groq \
|
|
528
503
|
--base-url https://api.groq.com/openai/v1 \
|
|
529
504
|
--api-key-env GROQ_API_KEY \
|
|
530
505
|
--model llama-3.3-70b-versatile
|
|
531
506
|
|
|
532
507
|
# Mistral
|
|
533
|
-
export MISTRAL_API_KEY=...
|
|
534
508
|
aiv config add-provider mistral \
|
|
535
509
|
--base-url https://api.mistral.ai/v1 \
|
|
536
510
|
--api-key-env MISTRAL_API_KEY \
|
|
@@ -548,26 +522,25 @@ aiv config add-provider together \
|
|
|
548
522
|
--api-key-env TOGETHER_API_KEY \
|
|
549
523
|
--model meta-llama/Llama-3-70b-chat-hf
|
|
550
524
|
|
|
551
|
-
# Ollama (local, no key
|
|
525
|
+
# Ollama (local, no key required)
|
|
552
526
|
aiv config add-provider ollama \
|
|
553
527
|
--base-url http://localhost:11434/v1 \
|
|
554
528
|
--api-key-env OLLAMA_API_KEY \
|
|
555
529
|
--model llama3.2
|
|
556
|
-
```
|
|
557
530
|
|
|
558
|
-
|
|
559
|
-
|
|
560
|
-
|
|
561
|
-
|
|
562
|
-
|
|
563
|
-
aiv config set-fallback groq openai
|
|
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
|
|
564
536
|
```
|
|
565
537
|
|
|
566
|
-
|
|
538
|
+
Once registered, custom providers work exactly like built-ins:
|
|
567
539
|
|
|
568
540
|
```bash
|
|
569
|
-
aiv config
|
|
570
|
-
aiv config
|
|
541
|
+
aiv config set-provider kimi
|
|
542
|
+
aiv config list-providers # built-ins + custom
|
|
543
|
+
aiv config remove-provider kimi
|
|
571
544
|
aiv config add-provider kimi --model moonshot-v1-32k --force # update
|
|
572
545
|
```
|
|
573
546
|
|
|
@@ -575,36 +548,41 @@ aiv config add-provider kimi --model moonshot-v1-32k --force # update
|
|
|
575
548
|
|
|
576
549
|
### Per-agent provider assignment
|
|
577
550
|
|
|
578
|
-
|
|
551
|
+
Each agent (and the context generator) can use a different provider or model:
|
|
579
552
|
|
|
580
553
|
```bash
|
|
554
|
+
# Assign provider/model per agent
|
|
581
555
|
aiv config set-agent-provider business claude/claude-sonnet-4-6
|
|
582
556
|
aiv config set-agent-provider security openai/gpt-4.1
|
|
583
557
|
aiv config set-agent-provider architecture gemini/gemini-2.0-flash
|
|
584
558
|
aiv config set-agent-provider context kimi/moonshot-v1-8k
|
|
585
559
|
|
|
560
|
+
# Use just a provider name (uses that provider's default model)
|
|
561
|
+
aiv config set-agent-provider business groq
|
|
562
|
+
|
|
586
563
|
# View current assignments
|
|
587
564
|
aiv config show-agents
|
|
588
565
|
|
|
589
|
-
# Remove
|
|
566
|
+
# Remove override (reverts to default provider)
|
|
590
567
|
aiv config set-agent-provider business --clear
|
|
591
568
|
```
|
|
592
569
|
|
|
570
|
+
Valid agent roles: `business`, `architecture`, `security`, `context`.
|
|
571
|
+
|
|
572
|
+
The `context` role is used by `aiv context generate`. All other roles map to the review agents.
|
|
573
|
+
|
|
593
574
|
---
|
|
594
575
|
|
|
595
576
|
### Fallback chain
|
|
596
577
|
|
|
597
|
-
If
|
|
578
|
+
If any provider hits a rate limit or quota error (HTTP 429, overloaded, insufficient quota), aiv automatically switches to the next provider in the chain — for the rest of that run.
|
|
598
579
|
|
|
599
580
|
```bash
|
|
600
|
-
|
|
601
|
-
aiv config set-fallback
|
|
602
|
-
|
|
603
|
-
# Clear the chain
|
|
604
|
-
aiv config set-fallback
|
|
581
|
+
aiv config set-fallback openai gemini groq # try in this order
|
|
582
|
+
aiv config set-fallback # clear the chain
|
|
605
583
|
```
|
|
606
584
|
|
|
607
|
-
When a fallback fires
|
|
585
|
+
When a fallback fires:
|
|
608
586
|
|
|
609
587
|
```
|
|
610
588
|
⚡ "claude" quota/rate limit — switching to "openai"
|
|
@@ -618,17 +596,14 @@ When a fallback fires, aiv prints:
|
|
|
618
596
|
aiv config set-provider mock
|
|
619
597
|
```
|
|
620
598
|
|
|
621
|
-
Returns deterministic placeholder findings. Use this to test the CLI
|
|
599
|
+
Returns deterministic placeholder findings. Use this to test the CLI without consuming API credits.
|
|
622
600
|
|
|
623
601
|
---
|
|
624
602
|
|
|
625
603
|
## Review Output
|
|
626
604
|
|
|
627
|
-
A typical review looks like:
|
|
628
|
-
|
|
629
605
|
```
|
|
630
606
|
aiv review — PR #42
|
|
631
|
-
|
|
632
607
|
Account: personal (GITHUB_TOKEN)
|
|
633
608
|
|
|
634
609
|
✔ PR loaded: "Add payment retry logic" (8 files)
|
|
@@ -649,10 +624,8 @@ A typical review looks like:
|
|
|
649
624
|
───────────────
|
|
650
625
|
[HIGH] Missing idempotency key on retry
|
|
651
626
|
File: src/payments/retry.ts
|
|
652
|
-
|
|
653
|
-
the
|
|
654
|
-
Suggestion: Pass a stable idempotency key derived from the
|
|
655
|
-
original transaction ID.
|
|
627
|
+
Suggestion: Pass a stable idempotency key derived from
|
|
628
|
+
the original transaction ID.
|
|
656
629
|
|
|
657
630
|
Business Risks
|
|
658
631
|
──────────────
|
|
@@ -662,8 +635,6 @@ A typical review looks like:
|
|
|
662
635
|
Architecture Issues
|
|
663
636
|
───────────────────
|
|
664
637
|
[MEDIUM] Direct database write outside billing module
|
|
665
|
-
src/payments/retry.ts imports UserBalance from outside
|
|
666
|
-
the billing boundary.
|
|
667
638
|
|
|
668
639
|
Agent Summaries
|
|
669
640
|
───────────────
|
|
@@ -674,8 +645,6 @@ A typical review looks like:
|
|
|
674
645
|
|
|
675
646
|
### Risk score
|
|
676
647
|
|
|
677
|
-
Computed as `max_score × 0.6 + average_score × 0.4` across all agents.
|
|
678
|
-
|
|
679
648
|
| Score | Label |
|
|
680
649
|
|--------|----------|
|
|
681
650
|
| 0–25 | LOW |
|
|
@@ -683,62 +652,95 @@ Computed as `max_score × 0.6 + average_score × 0.4` across all agents.
|
|
|
683
652
|
| 51–75 | HIGH |
|
|
684
653
|
| 76–100 | CRITICAL |
|
|
685
654
|
|
|
686
|
-
|
|
655
|
+
Computed as `max_score × 0.6 + average_score × 0.4` across all agents.
|
|
687
656
|
|
|
688
|
-
|
|
657
|
+
### JSON output
|
|
689
658
|
|
|
690
659
|
```bash
|
|
691
660
|
aiv review 42 --json | jq '.riskScore'
|
|
692
661
|
aiv review 42 --json > review-42.json
|
|
693
662
|
```
|
|
694
663
|
|
|
695
|
-
|
|
664
|
+
Shape: `prNumber`, `prTitle`, `riskScore`, `riskLabel`, `executiveSummary`, `agents[]`, `securityIssues[]`, `businessRisks[]`, `architectureIssues[]`, `possibleRegressions[]`.
|
|
665
|
+
|
|
666
|
+
`--json` skips the post-review action prompt.
|
|
696
667
|
|
|
697
668
|
---
|
|
698
669
|
|
|
699
|
-
##
|
|
670
|
+
## Post-review Actions
|
|
671
|
+
|
|
672
|
+
After every review in an interactive terminal, aiv asks:
|
|
673
|
+
|
|
674
|
+
```
|
|
675
|
+
? What would you like to do with this PR?
|
|
676
|
+
❯ ✔ Approve PR
|
|
677
|
+
⚑ Request Changes
|
|
678
|
+
────────────────────────────────────────
|
|
679
|
+
↩ Skip
|
|
680
|
+
```
|
|
681
|
+
|
|
682
|
+
- **Approve** — submits an `APPROVE` review to GitHub. aiv then asks if you want to merge:
|
|
683
|
+
|
|
684
|
+
```
|
|
685
|
+
? Merge this PR now? (y/N)
|
|
686
|
+
|
|
687
|
+
? Select merge strategy:
|
|
688
|
+
❯ Squash and merge
|
|
689
|
+
Merge commit
|
|
690
|
+
Rebase and merge
|
|
691
|
+
```
|
|
692
|
+
|
|
693
|
+
After approving (with or without merge), `context.md` and `tree.json` are refreshed automatically.
|
|
700
694
|
|
|
701
|
-
|
|
695
|
+
- **Request Changes** — submits a `REQUEST_CHANGES` review to GitHub.
|
|
696
|
+
- **Skip** — does nothing, exits cleanly.
|
|
697
|
+
|
|
698
|
+
---
|
|
699
|
+
|
|
700
|
+
## Multi-language
|
|
702
701
|
|
|
703
|
-
|
|
702
|
+
aiv supports English and Spanish. All output — errors, spinners, table headers, severity labels, and AI agent responses — follows the configured language.
|
|
704
703
|
|
|
705
704
|
```bash
|
|
706
|
-
# Permanently (saved to ~/.aiv/config.yml)
|
|
707
705
|
aiv config set-lang es
|
|
708
706
|
aiv config set-lang en
|
|
709
707
|
|
|
710
|
-
#
|
|
711
|
-
AIV_LANG=es aiv prs
|
|
712
|
-
AIV_LANG=en aiv review 42
|
|
708
|
+
AIV_LANG=es aiv prs # per-session override
|
|
713
709
|
```
|
|
714
710
|
|
|
715
|
-
###
|
|
711
|
+
### Detection order
|
|
716
712
|
|
|
717
713
|
1. `AIV_LANG` environment variable
|
|
718
714
|
2. `lang` in `~/.aiv/config.yml`
|
|
719
|
-
3. System `LANG`
|
|
715
|
+
3. System `LANG` variable (`es_*` locales → Spanish)
|
|
720
716
|
4. Default: `en`
|
|
721
717
|
|
|
722
718
|
---
|
|
723
719
|
|
|
724
720
|
## Environment Variables
|
|
725
721
|
|
|
726
|
-
| Variable
|
|
727
|
-
|
|
728
|
-
| `GITHUB_TOKEN`
|
|
729
|
-
| `CLAUDE_API_KEY`
|
|
730
|
-
| `OPENAI_API_KEY`
|
|
731
|
-
| `
|
|
732
|
-
| `
|
|
722
|
+
| Variable | Required | Description |
|
|
723
|
+
|----------|----------|-------------|
|
|
724
|
+
| `GITHUB_TOKEN` | Yes | GitHub personal access token (default account) |
|
|
725
|
+
| `CLAUDE_API_KEY` | Yes* | Anthropic API key (*when using Claude) |
|
|
726
|
+
| `OPENAI_API_KEY` | Yes* | OpenAI API key (*when using OpenAI) |
|
|
727
|
+
| `GEMINI_API_KEY` | Yes* | Google AI API key (*when using Gemini) |
|
|
728
|
+
| `AIV_LANG` | No | Override display language (`en` or `es`) |
|
|
729
|
+
| `LANG` | No | System locale (auto-detected by aiv) |
|
|
733
730
|
|
|
734
|
-
For
|
|
731
|
+
For custom providers, the env var name is whatever you passed to `--api-key-env`:
|
|
735
732
|
|
|
736
733
|
```bash
|
|
737
|
-
export
|
|
738
|
-
aiv config add-
|
|
734
|
+
export KIMI_API_KEY=sk-...
|
|
735
|
+
aiv config add-provider kimi --api-key-env KIMI_API_KEY ...
|
|
739
736
|
```
|
|
740
737
|
|
|
741
|
-
GitHub
|
|
738
|
+
### GitHub token permissions
|
|
739
|
+
|
|
740
|
+
| Scope | Required for |
|
|
741
|
+
|-------|-------------|
|
|
742
|
+
| `repo` (private repos) or `public_repo` | Reading PRs and diffs |
|
|
743
|
+
| `pull_requests: write` (fine-grained PAT) | Submitting reviews and merging |
|
|
742
744
|
|
|
743
745
|
---
|
|
744
746
|
|
|
@@ -746,26 +748,21 @@ GitHub tokens require `repo` scope to read pull requests and diffs.
|
|
|
746
748
|
|
|
747
749
|
### `Not initialized. Run aiv init first.`
|
|
748
750
|
|
|
749
|
-
|
|
751
|
+
`.aiv/config.yml` does not exist in the current directory.
|
|
750
752
|
|
|
751
753
|
```bash
|
|
752
|
-
cd your-repo
|
|
753
|
-
aiv init
|
|
754
|
+
cd your-repo && aiv init
|
|
754
755
|
```
|
|
755
756
|
|
|
756
757
|
---
|
|
757
758
|
|
|
758
759
|
### `Missing env var: GITHUB_TOKEN (account: default)`
|
|
759
760
|
|
|
760
|
-
The token env var for the active account is not set
|
|
761
|
+
The token env var for the active account is not set.
|
|
761
762
|
|
|
762
763
|
```bash
|
|
763
764
|
export GITHUB_TOKEN=ghp_...
|
|
764
|
-
|
|
765
|
-
|
|
766
|
-
If you use a named account with a different env var, check which account is active and what it expects:
|
|
767
|
-
|
|
768
|
-
```bash
|
|
765
|
+
# or check which account/var is active:
|
|
769
766
|
aiv config accounts
|
|
770
767
|
```
|
|
771
768
|
|
|
@@ -773,71 +770,60 @@ aiv config accounts
|
|
|
773
770
|
|
|
774
771
|
### `Missing env var: CLAUDE_API_KEY`
|
|
775
772
|
|
|
776
|
-
The AI provider API key is not set. Set the env var or switch providers:
|
|
777
|
-
|
|
778
773
|
```bash
|
|
779
774
|
export CLAUDE_API_KEY=sk-ant-...
|
|
780
|
-
# or switch
|
|
775
|
+
# or switch providers:
|
|
781
776
|
aiv config set-provider openai
|
|
782
|
-
export OPENAI_API_KEY=sk-...
|
|
783
777
|
```
|
|
784
778
|
|
|
785
779
|
---
|
|
786
780
|
|
|
787
|
-
### `
|
|
781
|
+
### `Unknown provider: "xyz".`
|
|
788
782
|
|
|
789
|
-
|
|
783
|
+
A provider name was used that isn't registered.
|
|
790
784
|
|
|
791
|
-
Fix — pass flags directly:
|
|
792
785
|
```bash
|
|
793
|
-
aiv
|
|
794
|
-
aiv
|
|
795
|
-
```
|
|
796
|
-
|
|
797
|
-
Fix — set permanently in repo config:
|
|
798
|
-
```bash
|
|
799
|
-
aiv config set-repo myorg myrepo
|
|
786
|
+
aiv config list-providers # see what's configured
|
|
787
|
+
aiv config add-provider xyz --base-url <url> --api-key-env XYZ_API_KEY --model <model>
|
|
800
788
|
```
|
|
801
789
|
|
|
802
790
|
---
|
|
803
791
|
|
|
804
|
-
### `
|
|
792
|
+
### `Could not detect GitHub owner/repo.`
|
|
805
793
|
|
|
806
|
-
|
|
794
|
+
The git remote is missing or not a GitHub URL.
|
|
807
795
|
|
|
808
796
|
```bash
|
|
809
|
-
aiv
|
|
810
|
-
|
|
797
|
+
aiv prs --owner myorg --repo myrepo
|
|
798
|
+
# or set permanently:
|
|
799
|
+
aiv config set-repo myorg myrepo
|
|
811
800
|
```
|
|
812
801
|
|
|
813
802
|
---
|
|
814
803
|
|
|
815
|
-
### `Account "xyz"
|
|
804
|
+
### `Account "xyz" not found.`
|
|
816
805
|
|
|
817
806
|
```bash
|
|
818
|
-
aiv config
|
|
807
|
+
aiv config accounts
|
|
808
|
+
aiv config add-account xyz --token-env MY_TOKEN
|
|
819
809
|
```
|
|
820
810
|
|
|
821
811
|
---
|
|
822
812
|
|
|
823
813
|
### `Failed to fetch PR: ...`
|
|
824
814
|
|
|
825
|
-
|
|
826
|
-
|
|
827
|
-
-
|
|
828
|
-
-
|
|
829
|
-
- GitHub rate limit hit — wait or switch to a token with higher limits
|
|
830
|
-
- Wrong `owner`/`repo` — verify with `aiv config show`
|
|
815
|
+
- Token lacks `repo` scope — regenerate
|
|
816
|
+
- PR number doesn't exist
|
|
817
|
+
- GitHub rate limit — wait or switch token
|
|
818
|
+
- Wrong owner/repo — check with `aiv config show`
|
|
831
819
|
|
|
832
820
|
---
|
|
833
821
|
|
|
834
822
|
### `Review failed: ...`
|
|
835
823
|
|
|
836
|
-
|
|
837
|
-
|
|
838
|
-
-
|
|
839
|
-
- Model quota exceeded
|
|
840
|
-
- Network timeout on a very large diff — reduce `max_tokens` in config:
|
|
824
|
+
- API key invalid or expired
|
|
825
|
+
- Model quota exceeded — configure a [fallback chain](#fallback-chain)
|
|
826
|
+
- Diff too large — reduce `max_tokens`:
|
|
841
827
|
|
|
842
828
|
```yaml
|
|
843
829
|
# .aiv/config.yml
|
|
@@ -849,81 +835,90 @@ review:
|
|
|
849
835
|
|
|
850
836
|
## Best Practices
|
|
851
837
|
|
|
852
|
-
###
|
|
838
|
+
### Let AI bootstrap your context and rules
|
|
839
|
+
|
|
840
|
+
Right after `aiv init`, run:
|
|
841
|
+
|
|
842
|
+
```bash
|
|
843
|
+
aiv context generate
|
|
844
|
+
```
|
|
853
845
|
|
|
854
|
-
|
|
846
|
+
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.
|
|
855
847
|
|
|
856
|
-
###
|
|
848
|
+
### Keep rules.yml current
|
|
857
849
|
|
|
858
|
-
Add a rule
|
|
850
|
+
Add a rule whenever your team agrees on a pattern reviews should catch:
|
|
859
851
|
|
|
860
852
|
```yaml
|
|
861
853
|
business_rules:
|
|
862
854
|
orders:
|
|
863
|
-
required_calls:
|
|
864
|
-
|
|
865
|
-
forbidden_patterns:
|
|
866
|
-
- skipFraudCheck
|
|
855
|
+
required_calls: [validateInventory]
|
|
856
|
+
forbidden_patterns: [skipFraudCheck]
|
|
867
857
|
```
|
|
868
858
|
|
|
869
|
-
### Refresh context after
|
|
859
|
+
### Refresh context after structural changes
|
|
870
860
|
|
|
871
861
|
```bash
|
|
872
862
|
aiv context refresh
|
|
873
863
|
```
|
|
874
864
|
|
|
875
|
-
Run
|
|
865
|
+
Run after merging large refactors, adding modules, or changing the project layout.
|
|
876
866
|
|
|
877
|
-
### Use
|
|
878
|
-
|
|
879
|
-
Not every PR needs all three agents. If you're reviewing a dependency bump, only security matters. If it's a UI-only change, skip security and architecture:
|
|
867
|
+
### Use a fallback chain for reliability
|
|
880
868
|
|
|
881
869
|
```bash
|
|
882
|
-
aiv
|
|
883
|
-
aiv review 202 --agent business architecture
|
|
870
|
+
aiv config set-fallback openai gemini
|
|
884
871
|
```
|
|
885
872
|
|
|
886
|
-
|
|
873
|
+
If your primary provider is rate-limited mid-review, aiv switches automatically without losing the run.
|
|
887
874
|
|
|
888
|
-
###
|
|
875
|
+
### Match model to task with per-agent assignment
|
|
889
876
|
|
|
890
|
-
|
|
877
|
+
Use a fast/cheap model for straightforward agents and a powerful one for the critical ones:
|
|
891
878
|
|
|
892
879
|
```bash
|
|
893
|
-
aiv config
|
|
894
|
-
|
|
895
|
-
|
|
896
|
-
--description "Personal GitHub"
|
|
880
|
+
aiv config set-agent-provider business claude/claude-haiku-4-5
|
|
881
|
+
aiv config set-agent-provider architecture claude/claude-haiku-4-5
|
|
882
|
+
aiv config set-agent-provider security claude/claude-sonnet-4-6 # strongest model here
|
|
897
883
|
```
|
|
898
884
|
|
|
885
|
+
### Use `--agent` to narrow focus
|
|
886
|
+
|
|
887
|
+
```bash
|
|
888
|
+
aiv review 101 --agent security # dependency bump
|
|
889
|
+
aiv review 202 --agent business architecture # domain change
|
|
890
|
+
```
|
|
891
|
+
|
|
892
|
+
Fewer agents = faster, cheaper, more focused output.
|
|
893
|
+
|
|
899
894
|
### Commit `.aiv/` to the repository
|
|
900
895
|
|
|
901
|
-
Committing `config.yml`, `rules.yml`, and `context.md` means every team member gets identical review behavior
|
|
896
|
+
Committing `config.yml`, `rules.yml`, and `context.md` means every team member gets identical review behavior with no setup. Only exclude `tree.json`:
|
|
902
897
|
|
|
903
898
|
```
|
|
904
899
|
# .gitignore
|
|
905
900
|
.aiv/tree.json
|
|
906
901
|
```
|
|
907
902
|
|
|
908
|
-
`aiv init` adds this
|
|
903
|
+
`aiv init` adds this automatically.
|
|
909
904
|
|
|
910
|
-
###
|
|
905
|
+
### CI integration with `--json`
|
|
911
906
|
|
|
912
907
|
```bash
|
|
913
908
|
SCORE=$(aiv review $PR_NUMBER --json | jq '.riskScore')
|
|
914
909
|
if [ "$SCORE" -gt 75 ]; then
|
|
915
|
-
echo "High-risk PR — human review required
|
|
910
|
+
echo "High-risk PR — human review required"
|
|
916
911
|
exit 1
|
|
917
912
|
fi
|
|
918
913
|
```
|
|
919
914
|
|
|
920
915
|
### What aiv is not
|
|
921
916
|
|
|
922
|
-
- Not a linter
|
|
923
|
-
- Not a replacement for static analysis
|
|
924
|
-
- Not
|
|
917
|
+
- Not a linter — it won't flag semicolons or indentation
|
|
918
|
+
- Not a replacement for static analysis (ESLint, SonarQube)
|
|
919
|
+
- Not a style checker
|
|
925
920
|
|
|
926
|
-
Its value is **semantic understanding**: catching
|
|
921
|
+
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.
|
|
927
922
|
|
|
928
923
|
---
|
|
929
924
|
|
|
@@ -931,20 +926,30 @@ Its value is **semantic understanding**: catching what automated tools miss —
|
|
|
931
926
|
|
|
932
927
|
```
|
|
933
928
|
src/
|
|
934
|
-
agents/ — business, architecture, security
|
|
929
|
+
agents/ — business, architecture, security reviewers
|
|
935
930
|
cli/
|
|
936
|
-
commands/ —
|
|
931
|
+
commands/ — init, prs, review, config, context, agents
|
|
937
932
|
banner.ts — ASCII welcome banner
|
|
938
933
|
renderer.ts — review result pretty-printer
|
|
939
|
-
selector.ts — interactive PR picker (inquirer)
|
|
934
|
+
selector.ts — interactive PR/action picker (inquirer)
|
|
940
935
|
config/ — two-level config load/save/merge
|
|
941
|
-
context/
|
|
942
|
-
|
|
936
|
+
context/
|
|
937
|
+
builder.ts — static project analysis
|
|
938
|
+
generator.ts — AI-powered context + rules generation
|
|
939
|
+
manager.ts — context reader + refreshContextFiles helper
|
|
940
|
+
tree.ts — file tree scanner
|
|
941
|
+
git/ — GitHub REST client + remote detection
|
|
943
942
|
i18n/ — EN/ES translations (all user-facing strings)
|
|
944
943
|
orchestrator/ — runs agents in parallel, aggregates results
|
|
945
|
-
providers/
|
|
944
|
+
providers/
|
|
945
|
+
claude.ts — Anthropic adapter
|
|
946
|
+
openai.ts — OpenAI adapter (supports custom baseURL)
|
|
947
|
+
gemini.ts — Google Gemini REST adapter
|
|
948
|
+
fallback.ts — FallbackProvider (quota/rate pivot)
|
|
949
|
+
factory.ts — resolves provider by name or agent role
|
|
950
|
+
mock.ts — offline test provider
|
|
946
951
|
types.ts — shared TypeScript interfaces
|
|
947
|
-
index.ts — CLI entry point
|
|
952
|
+
index.ts — CLI entry point
|
|
948
953
|
```
|
|
949
954
|
|
|
950
955
|
---
|