pi-auto-reviewer 1.0.1 → 1.0.3

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.
Files changed (3) hide show
  1. package/README.md +38 -36
  2. package/auto-reviewer.ts +725 -691
  3. package/package.json +1 -1
package/README.md CHANGED
@@ -1,16 +1,16 @@
1
1
  # pi-auto-reviewer
2
2
 
3
- Automatically review bash commands that your pi agent wants to execute - akin to Codex "Auto-review" and Claude Code "auto mode".
3
+ Automatically review shell commands (PowerShell or bash) that your pi agent wants to execute — akin to Codex "Auto-review" and Claude Code "auto mode".
4
4
 
5
5
  ## How it works
6
6
 
7
- Every bash command the agent wants to run goes through three tiers:
7
+ Every shell command (PowerShell or bash) the agent wants to run goes through three tiers:
8
8
 
9
9
  | Tier | Action | Examples |
10
10
  |------|--------|----------|
11
11
  | **1. Auto-permitted** | Runs immediately | `ls`, `cd`, `grep`, `git status`, `npm list`, `echo` |
12
- | **2. Auto-blocked** | Refused immediately | `rm -rf`, `sudo`, `chmod 777`, `git push --force`, `shutdown` |
13
- | **3. Needs review** | Sent to a reviewer LLM | `git commit`, `npm install`, `curl`, `mv`, `sed -i`, `cp` |
12
+ | **2. Auto-blocked** | Refused immediately | `rm -rf`, `sudo`, `chmod 777`, `git push --force`, `Remove-Item -Recurse`, `Start-Process -Verb RunAs` |
13
+ | **3. Needs review** | Sent to a reviewer LLM | `git commit`, `npm install`, `curl`, `mv`, `sed -i`, `cp`, `New-Item`, `Set-Content` |
14
14
 
15
15
  When a command falls into **Tier 3**, a subagent LLM reviews the command with project context and decides ALLOW or BLOCK.
16
16
 
@@ -44,45 +44,47 @@ Pi auto-discovers extensions in `.pi/extensions/` when the project is trusted.
44
44
  pi -e ./auto-reviewer.ts
45
45
  ```
46
46
 
47
+ On native Windows PowerShell, use the matching PowerShell copy commands and extension directory paths for your Pi install. The command rules include common PowerShell read-only commands such as `Get-Location`, `Get-ChildItem`, `Get-Content`, and `Test-Path`, plus Windows destructive/elevation patterns such as `Remove-Item -Recurse`, `cmd /c rmdir /s`, and `Start-Process -Verb RunAs`.
48
+
47
49
  ## Usage
48
50
 
49
- Once installed, it works automatically - no configuration required. Every bash command the agent tries to run will be reviewed.
51
+ Once installed, it works automatically — no configuration required. Every shell command the agent tries to run will be reviewed.
50
52
 
51
53
  ### What to expect
52
54
 
53
55
  - **Safe commands** (Tier 1) run without any visible delay.
54
56
  - **Dangerous commands** (Tier 2) are blocked with a notification explaining why.
55
- - **Everything else** (Tier 3) pauses briefly while the reviewer LLM decides. You'll see a status message: `Reviewing: <command>...`
57
+ - **Everything else** (Tier 3) pauses while the reviewer LLM decides (up to 60s per attempt, with one automatic retry on failure). You'll see a status message: `Reviewing: <command>...`
56
58
 
57
59
  - If **allowed**: the command runs and you see `Auto-reviewer: ✓ <reason>`
58
60
  - If **blocked**: the command is refused and you see `Auto-reviewer: ✗ <reason>`
59
- - If the reviewer **fails** (timeout, error): you're prompted interactively to allow or deny manually.
60
-
61
- ### Non-interactive mode
62
-
63
- In print mode (`pi -p`) or JSON mode, Tier 3 commands are blocked by default since there's no UI to fall back on.
64
-
65
- ## Configuration
66
-
67
- By default, Tier 3 review uses your normal pi inference provider and model. You can route reviewer calls to a specific provider and model with environment variables:
68
-
69
- | Variable | Purpose |
70
- |----------|---------|
71
- | `PI_REVIEWER_PROVIDER` | Inference provider for the reviewer subprocess, for example `opencode-go` |
72
- | `PI_REVIEWER_MODEL` | Model for the reviewer subprocess, for example `deepseek-v4-flash` |
73
-
74
- Set both variables together:
75
-
76
- ```bash
77
- export PI_REVIEWER_PROVIDER=opencode-go
78
- export PI_REVIEWER_MODEL=deepseek-v4-flash
79
- pi
80
- ```
81
-
82
- `export` only affects the current shell session. To keep these settings across new terminals, add the two `export` lines to your shell startup file, for example `~/.bashrc` on many Linux and WSL setups. Other shells use different files, such as `~/.zshrc` for zsh.
83
-
84
- If either variable is missing or empty, the reviewer uses pi's configured default provider and model. This avoids accidentally selecting a model name from the wrong provider when the same model id is available in more than one place.
85
-
86
- ## Customizing review rules
87
-
88
- Edit `AUTO_PERMITTED` and `AUTO_BLOCKED` arrays in `auto-reviewer.ts` to add or remove patterns. Edit `buildReviewPrompt()` to change how the reviewer LLM decides.
61
+ - If the reviewer **fails** on both attempts (timeout, error): you're prompted interactively to allow or deny manually.
62
+
63
+ ### Non-interactive mode
64
+
65
+ In print mode (`pi -p`) or JSON mode, Tier 3 commands are blocked by default since there's no UI to fall back on.
66
+
67
+ ## Configuration
68
+
69
+ By default, Tier 3 review uses your normal pi inference provider and model. You can route reviewer calls to a specific provider and model with environment variables:
70
+
71
+ | Variable | Purpose |
72
+ |----------|---------|
73
+ | `PI_REVIEWER_PROVIDER` | Inference provider for the reviewer subprocess, for example `opencode-go` |
74
+ | `PI_REVIEWER_MODEL` | Model for the reviewer subprocess, for example `deepseek-v4-flash` |
75
+
76
+ Set both variables together:
77
+
78
+ ```bash
79
+ export PI_REVIEWER_PROVIDER=opencode-go
80
+ export PI_REVIEWER_MODEL=deepseek-v4-flash
81
+ pi
82
+ ```
83
+
84
+ `export` only affects the current shell session. To keep these settings across new terminals, add the two `export` lines to your shell startup file, for example `~/.bashrc` on many Linux and WSL setups. Other shells use different files, such as `~/.zshrc` for zsh.
85
+
86
+ If either variable is missing or empty, the reviewer uses pi's configured default provider and model. This avoids accidentally selecting a model name from the wrong provider when the same model id is available in more than one place.
87
+
88
+ ## Customizing review rules
89
+
90
+ Edit `AUTO_PERMITTED` and `AUTO_BLOCKED` arrays in `auto-reviewer.ts` to add or remove patterns. Edit `buildReviewPrompt()` to change how the reviewer LLM decides.