reviewd 0.1.0__tar.gz

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.
@@ -0,0 +1,10 @@
1
+ __pycache__/
2
+ *.pyc
3
+ *.egg-info/
4
+ dist/
5
+ build/
6
+ .reviewd-worktrees/
7
+ *.db
8
+ .venv/
9
+ .env
10
+ .env.*
@@ -0,0 +1,25 @@
1
+ repos:
2
+ - repo: https://github.com/Yelp/detect-secrets
3
+ rev: v1.5.0
4
+ hooks:
5
+ - id: detect-secrets
6
+ args: ['--baseline', '.secrets.baseline']
7
+
8
+ - repo: https://github.com/pre-commit/pre-commit-hooks
9
+ rev: v5.0.0
10
+ hooks:
11
+ - id: check-ast
12
+ - id: check-yaml
13
+ - id: check-added-large-files
14
+
15
+ - repo: https://github.com/astral-sh/ruff-pre-commit
16
+ rev: v0.8.6
17
+ hooks:
18
+ - id: ruff
19
+ args: [--fix]
20
+ - id: ruff-format
21
+
22
+ - repo: https://github.com/psf/black
23
+ rev: 24.10.0
24
+ hooks:
25
+ - id: black
@@ -0,0 +1,127 @@
1
+ {
2
+ "version": "1.5.0",
3
+ "plugins_used": [
4
+ {
5
+ "name": "ArtifactoryDetector"
6
+ },
7
+ {
8
+ "name": "AWSKeyDetector"
9
+ },
10
+ {
11
+ "name": "AzureStorageKeyDetector"
12
+ },
13
+ {
14
+ "name": "Base64HighEntropyString",
15
+ "limit": 4.5
16
+ },
17
+ {
18
+ "name": "BasicAuthDetector"
19
+ },
20
+ {
21
+ "name": "CloudantDetector"
22
+ },
23
+ {
24
+ "name": "DiscordBotTokenDetector"
25
+ },
26
+ {
27
+ "name": "GitHubTokenDetector"
28
+ },
29
+ {
30
+ "name": "GitLabTokenDetector"
31
+ },
32
+ {
33
+ "name": "HexHighEntropyString",
34
+ "limit": 3.0
35
+ },
36
+ {
37
+ "name": "IbmCloudIamDetector"
38
+ },
39
+ {
40
+ "name": "IbmCosHmacDetector"
41
+ },
42
+ {
43
+ "name": "IPPublicDetector"
44
+ },
45
+ {
46
+ "name": "JwtTokenDetector"
47
+ },
48
+ {
49
+ "name": "KeywordDetector",
50
+ "keyword_exclude": ""
51
+ },
52
+ {
53
+ "name": "MailchimpDetector"
54
+ },
55
+ {
56
+ "name": "NpmDetector"
57
+ },
58
+ {
59
+ "name": "OpenAIDetector"
60
+ },
61
+ {
62
+ "name": "PrivateKeyDetector"
63
+ },
64
+ {
65
+ "name": "PypiTokenDetector"
66
+ },
67
+ {
68
+ "name": "SendGridDetector"
69
+ },
70
+ {
71
+ "name": "SlackDetector"
72
+ },
73
+ {
74
+ "name": "SoftlayerDetector"
75
+ },
76
+ {
77
+ "name": "SquareOAuthDetector"
78
+ },
79
+ {
80
+ "name": "StripeDetector"
81
+ },
82
+ {
83
+ "name": "TelegramBotTokenDetector"
84
+ },
85
+ {
86
+ "name": "TwilioKeyDetector"
87
+ }
88
+ ],
89
+ "filters_used": [
90
+ {
91
+ "path": "detect_secrets.filters.allowlist.is_line_allowlisted"
92
+ },
93
+ {
94
+ "path": "detect_secrets.filters.common.is_ignored_due_to_verification_policies",
95
+ "min_level": 2
96
+ },
97
+ {
98
+ "path": "detect_secrets.filters.heuristic.is_indirect_reference"
99
+ },
100
+ {
101
+ "path": "detect_secrets.filters.heuristic.is_likely_id_string"
102
+ },
103
+ {
104
+ "path": "detect_secrets.filters.heuristic.is_lock_file"
105
+ },
106
+ {
107
+ "path": "detect_secrets.filters.heuristic.is_not_alphanumeric_string"
108
+ },
109
+ {
110
+ "path": "detect_secrets.filters.heuristic.is_potential_uuid"
111
+ },
112
+ {
113
+ "path": "detect_secrets.filters.heuristic.is_prefixed_with_dollar_sign"
114
+ },
115
+ {
116
+ "path": "detect_secrets.filters.heuristic.is_sequential_string"
117
+ },
118
+ {
119
+ "path": "detect_secrets.filters.heuristic.is_swagger_file"
120
+ },
121
+ {
122
+ "path": "detect_secrets.filters.heuristic.is_templated_secret"
123
+ }
124
+ ],
125
+ "results": {},
126
+ "generated_at": "2026-03-04T08:49:36Z"
127
+ }
@@ -0,0 +1,104 @@
1
+ # CLAUDE.md — reviewd
2
+
3
+ ## What This Is
4
+
5
+ Local CLI tool that polls GitHub/BitBucket for open PRs, reviews them using Claude/Gemini CLI, and posts structured comments back. Invokes `claude --print` or `gemini -p` as local subprocesses — no API keys, uses existing CLI subscriptions.
6
+
7
+ ## Architecture
8
+
9
+ ```
10
+ Poller (GitHub/BB API) → State Check (SQLite) → Worktree (git) → AI Review (CLI) → Parse JSON → Post Comments
11
+ ```
12
+
13
+ - **Polling**, not webhooks — runs locally, no tunnel needed
14
+ - **Git worktrees** for isolation — no interference with working copy
15
+ - **AI has full tool access** — reads files, explores code, runs commands in the worktree
16
+ - **JSON output** — prompt requests structured JSON as last block, extracted via regex
17
+ - **SQLite** for state — tracks `(repo, pr_id, source_commit)` to avoid duplicate reviews
18
+ - **ID-based comment cleanup** — tracks posted comment IDs in SQLite, deletes by ID on re-review
19
+
20
+ ## Project Conventions
21
+
22
+ - Python 3.12+, no backward compatibility
23
+ - Dependencies managed with `uv`
24
+ - Google style, single quotes for strings, double quotes for messages
25
+ - No broad except clauses
26
+ - No unnecessary docstrings or comments
27
+ - Tests only when explicitly asked
28
+ - Never add Co-Authored-By to commits
29
+
30
+ ## Key Files
31
+
32
+ | File | Purpose |
33
+ |------|---------|
34
+ | `src/reviewd/cli.py` | Click CLI: `ls`, `watch`, `pr`, `status` commands |
35
+ | `src/reviewd/daemon.py` | Poll loop, boot summary, status line, orchestration, signal handling |
36
+ | `src/reviewd/reviewer.py` | Worktree lifecycle + AI CLI invocation (Popen) + JSON extraction |
37
+ | `src/reviewd/prompt.py` | Built-in review prompt template + builder |
38
+ | `src/reviewd/commenter.py` | Format findings as markdown, post via provider, delete old comments by ID |
39
+ | `src/reviewd/config.py` | YAML + `${ENV_VAR}` loading, global + per-project merge, provider factory |
40
+ | `src/reviewd/state.py` | SQLite: reviews + posted_comments (with get/delete by repo+PR) |
41
+ | `src/reviewd/models.py` | Dataclasses: PRInfo, Finding, ReviewResult, configs, CLI enum |
42
+ | `src/reviewd/providers/base.py` | Abstract GitProvider ABC |
43
+ | `src/reviewd/providers/bitbucket.py` | BitBucket 2.0 API (httpx, pagination with ID dedup, inline comments) |
44
+ | `src/reviewd/providers/github.py` | GitHub REST API v3 (httpx, Link header pagination, review comments) |
45
+
46
+ ## Config
47
+
48
+ ### Global: `~/.config/reviewd/config.yaml`
49
+
50
+ Provider credentials, repos list, poll interval, AI CLI choice, model, cli_args, global `instructions`, `review_title`, `footer`.
51
+
52
+ ### Per-project: `{repo_root}/.reviewd.yaml`
53
+
54
+ Project-specific `instructions`, `test_commands`, `inline_comments_for`, `approve_if_no_critical`, `critical_task`.
55
+
56
+ Instructions merge: global + per-project concatenated (global first). Old `guidelines`/`explore` fields still supported.
57
+
58
+ ### Per-repo overrides in global config
59
+
60
+ `cli`, `model`, `repo_slug` (decouples display name from API slug), per-repo provider credentials.
61
+
62
+ ## How the Review Works
63
+
64
+ 1. Fetch PR metadata from provider API
65
+ 2. Clean up stale worktrees from previous interrupted runs
66
+ 3. Create git worktree at `{repo}/.reviewd-worktrees/pr-{id}`
67
+ 4. Build prompt: PR metadata + merged instructions + validation commands + JSON schema
68
+ 5. Run `claude --print --model X -p "<prompt>"` or `gemini --approval-mode yolo -e none -p "<prompt>"` via Popen
69
+ 6. Stream stderr for progress, ticker thread logs elapsed time every 30s
70
+ 7. Extract last ```json``` block from stdout
71
+ 8. Delete old bot comments by tracked IDs from SQLite
72
+ 9. Post inline comments (single-line, with `suggestion` code fence) + summary comment
73
+ 10. Cleanup worktree
74
+
75
+ ## CLI
76
+
77
+ ```bash
78
+ reviewd init # create config file
79
+ reviewd ls # list repos + open PRs
80
+ reviewd watch -v # daemon mode
81
+ reviewd watch -v --review-existing # review not-yet-reviewed open PRs
82
+ reviewd watch -v --cli gemini # override AI CLI
83
+ reviewd pr pydpf 42 # one-shot review
84
+ reviewd pr pydpf 42 --dry-run # preview without posting
85
+ reviewd pr pydpf 42 --force # re-review even if already done
86
+ reviewd pr pydpf 42 --cli gemini # override AI CLI
87
+ reviewd status pydpf # review history
88
+ ```
89
+
90
+ ## Prompt Injection Defenses
91
+
92
+ - Prompt includes a security scope block (before any user-controlled content) that forbids file writes, network access, accessing secrets, and following instructions embedded in code
93
+ - Gemini CLI: `-e none` disables all extensions
94
+ - Project config (`.reviewd.yaml`) is read from the main repo, not the worktree — PR authors cannot inject instructions via config
95
+ - `test_commands` come only from the repo owner's config, not from PR content
96
+
97
+ ## Known Limitations
98
+
99
+ - BitBucket markdown doesn't support HTML comments — bot marker uses empty link `[](reviewd)`
100
+ - Can't `git fetch` by commit hash from BB — if source branch is deleted, commit must exist locally
101
+ - Claude CLI rejects nested sessions — must unset `CLAUDECODE` env var in subprocess
102
+ - Gemini CLI loads global extensions by default — use `-e none` to disable
103
+ - Inline suggestions are single-line only (TODO: multi-line support)
104
+ - AI may hallucinate line numbers — prompt instructs to double-check but not guaranteed
reviewd-0.1.0/LICENSE ADDED
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2025 Simion Agavriloaei
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
reviewd-0.1.0/PKG-INFO ADDED
@@ -0,0 +1,221 @@
1
+ Metadata-Version: 2.4
2
+ Name: reviewd
3
+ Version: 0.1.0
4
+ Summary: Local AI code reviewer for GitHub and BitBucket PRs — uses Claude or Gemini CLI to review pull requests and post structured comments
5
+ Project-URL: Homepage, https://github.com/simion/reviewd
6
+ Project-URL: Repository, https://github.com/simion/reviewd
7
+ Project-URL: Issues, https://github.com/simion/reviewd/issues
8
+ Author-email: Simion Agavriloaei <hi@simion.cv>
9
+ License-Expression: MIT
10
+ License-File: LICENSE
11
+ Keywords: ai,automation,bitbucket,claude,code-review,gemini,github,pull-request
12
+ Classifier: Development Status :: 4 - Beta
13
+ Classifier: Environment :: Console
14
+ Classifier: Intended Audience :: Developers
15
+ Classifier: License :: OSI Approved :: MIT License
16
+ Classifier: Programming Language :: Python :: 3.12
17
+ Classifier: Topic :: Software Development :: Quality Assurance
18
+ Requires-Python: >=3.12
19
+ Requires-Dist: click<9,>=8.1
20
+ Requires-Dist: httpx<1,>=0.27
21
+ Requires-Dist: pyyaml<7,>=6.0
22
+ Description-Content-Type: text/markdown
23
+
24
+ # reviewd
25
+
26
+ **The review daemon** — local AI code reviewer for GitHub and BitBucket pull requests, powered by Claude Code / Gemini CLI subscriptions.
27
+
28
+ - Watches your repos for new PRs, reviews them using Claude or Gemini CLI, and posts structured comments
29
+ - All from your machine — no CI pipeline, no cloud service, no new accounts
30
+ - Secure by default — can only access repos you already have locally, as secure as your machine
31
+
32
+ > If you already have `claude` or `gemini` CLI and local git clones, you're 5 minutes away from automated code reviews.
33
+
34
+ ## Features
35
+
36
+ - **Reuses what you already have** — your local git repos, your Claude/Gemini CLI subscription, your existing credentials. Nothing new to install or pay for.
37
+ - **Full codebase context** — reviews run on your actual local repos, not shallow CI clones. The AI can read any file, follow imports, and understand the full picture.
38
+ - **Fast via git worktrees** — isolated checkouts that share `.git`. No re-cloning. Reviews start in milliseconds.
39
+ - **Runs real commands** — configure linters, type checkers, and test suites to run during review. Failures are included in the AI's analysis.
40
+ - **Structured output** — severity-tagged findings with inline comments on specific lines and a summary comment.
41
+ - **Daemon or one-shot** — background polling across all repos, or single PR reviews on demand. Dry-run mode to preview.
42
+ - **Multi-repo, multi-AI** — different repos can use different AI backends, models, and review instructions.
43
+ - **Smart re-reviews** — new commits on a PR trigger a fresh review; old comments are deleted automatically.
44
+ - **Draft-aware** — skips draft PRs by default. Add `[review]`, `[claudiu]`, `[ask]`, or `[bot review]` to the title to request a review anyway.
45
+ - **Critical tasks** — optionally creates a BitBucket PR task on critical findings to block merge.
46
+ - **Spam protection** — configurable diff size thresholds, cooldowns, and title/author skip patterns.
47
+
48
+ ## Quick Start
49
+
50
+ ### 1. Install
51
+
52
+ ```bash
53
+ git clone https://github.com/simion/reviewd.git
54
+ cd reviewd
55
+ uv tool install -e .
56
+ ```
57
+
58
+ Requires Python 3.12+ and [`uv`](https://docs.astral.sh/uv/). You also need `claude` or `gemini` CLI installed and authenticated.
59
+
60
+ ### 2. Configure
61
+
62
+ ```bash
63
+ reviewd init # creates ~/.config/reviewd/config.yaml
64
+ ```
65
+
66
+ <details>
67
+ <summary><b>GitHub setup</b></summary>
68
+
69
+ 1. Create a [Personal Access Token](https://github.com/settings/tokens) with the **`repo`** scope.
70
+ 2. Export it: `export GITHUB_TOKEN=ghp_...`
71
+ 3. Config:
72
+
73
+ ```yaml
74
+ github:
75
+ token: ${GITHUB_TOKEN}
76
+
77
+ repos:
78
+ - name: my-repo
79
+ repo_slug: owner/my-repo
80
+ path: ~/repos/my-repo
81
+ provider: github
82
+ ```
83
+
84
+ </details>
85
+
86
+ <details>
87
+ <summary><b>BitBucket setup</b></summary>
88
+
89
+ 1. Create an [App Password](https://bitbucket.org/account/settings/app-passwords/) with **Pull requests: Read** and **Write**.
90
+ 2. Export it: `export BB_AUTH_TOKEN=ATCTT3x...`
91
+ 3. Config:
92
+
93
+ ```yaml
94
+ bitbucket:
95
+ your-workspace: ${BB_AUTH_TOKEN}
96
+
97
+ repos:
98
+ - name: my-project
99
+ path: ~/repos/my-project
100
+ provider: bitbucket
101
+ workspace: your-workspace
102
+ ```
103
+
104
+ </details>
105
+
106
+ Both providers can be used in the same config.
107
+
108
+ ### 3. Review
109
+
110
+ ```bash
111
+ reviewd pr my-project 42 # one-shot
112
+ reviewd pr my-project 42 --dry-run # preview
113
+ reviewd watch -v # daemon mode
114
+ ```
115
+
116
+ ## How It Works
117
+
118
+ ```
119
+ Poll API → Check State (SQLite) → Fetch & Worktree → AI Review (Claude/Gemini) → Parse JSON → Post Comments → Cleanup
120
+ ```
121
+
122
+ 1. Fetches open PRs from GitHub/BitBucket
123
+ 2. Skips already-reviewed commits, drafts, cooldowns, and small diffs
124
+ 3. Creates a git worktree, runs configured test commands
125
+ 4. Invokes the AI CLI with a structured prompt and JSON output schema
126
+ 5. Posts inline comments + summary comment, tracks state in SQLite
127
+
128
+ ## Configuration
129
+
130
+ ### Global (`~/.config/reviewd/config.yaml`)
131
+
132
+ ```yaml
133
+ poll_interval_seconds: 60
134
+
135
+ github:
136
+ token: ${GITHUB_TOKEN}
137
+
138
+ bitbucket:
139
+ your-workspace: ${BB_AUTH_TOKEN}
140
+ other-workspace: ${OTHER_BB_TOKEN}
141
+
142
+ cli: claude # or "gemini"
143
+ # model: claude-sonnet-4-5-20250514
144
+
145
+ # review_title: "Code Review by Nea' ~~Caisă~~ Claudiu"
146
+ # footer: "Automated review by ..."
147
+ # skip_title_patterns: ['[no-review]', '[wip]', '[no-claudiu]']
148
+ # skip_authors: []
149
+
150
+ instructions: |
151
+ Be concise and constructive.
152
+ Every issue must include a concrete suggested fix.
153
+
154
+ repos:
155
+ - name: gh-backend
156
+ repo_slug: owner/gh-backend
157
+ path: ~/repos/gh-backend
158
+ provider: github
159
+
160
+ - name: bb-frontend
161
+ path: ~/repos/bb-frontend
162
+ provider: bitbucket
163
+ workspace: your-workspace
164
+ cli: gemini
165
+ model: gemini-2.5-pro
166
+ ```
167
+
168
+ ### Per-project (`.reviewd.yaml` in repo root)
169
+
170
+ ```yaml
171
+ instructions: |
172
+ Python 3.12+, Django 5.x.
173
+ Check for missing select_related/prefetch_related.
174
+
175
+ test_commands:
176
+ - uv run ruff check .
177
+ - uv run pytest tests/ -x -q
178
+
179
+ skip_severities: [nitpick] # options: critical, suggestion, nitpick, good
180
+ inline_comments_for: [critical] # rest goes in summary
181
+ # max_inline_comments: 5 # skip all inline if exceeded
182
+ # min_diff_lines: 0 # initial review threshold (0 = disabled)
183
+ # min_diff_lines_update: 5 # re-review threshold for pushed commits
184
+ # review_cooldown_minutes: 30
185
+ # approve_if_no_critical: false
186
+ # critical_task: true # create PR task on critical findings (BitBucket)
187
+ ```
188
+
189
+ ## CLI Reference
190
+
191
+ ```bash
192
+ reviewd init # create config file
193
+ reviewd ls # list repos and open PRs
194
+ reviewd watch -v # daemon mode
195
+ reviewd watch -v --dry-run # preview, no posting
196
+ reviewd watch -v --review-existing # review not-yet-reviewed open PRs
197
+ reviewd pr <repo> <id> # one-shot review
198
+ reviewd pr <repo> <id> --force # re-review (bypasses draft/skip)
199
+ reviewd status <repo> # review history
200
+ ```
201
+
202
+ ## Architecture
203
+
204
+ - **Polling, not webhooks** — no tunnel or public endpoint needed
205
+ - **Git worktrees** — near-instant isolated checkouts
206
+ - **Full AI tool access** — the AI reads files, runs commands, explores code
207
+ - **JSON schema** — structured findings, the tool just parses and posts
208
+ - **SQLite state** — tracks `(repo, pr_id, commit)` to avoid duplicates
209
+ - **Provider abstraction** — GitHub and BitBucket, extensible
210
+
211
+ ## Security
212
+
213
+ > reviewd gives the AI CLI full tool access in git worktrees on your machine. Only watch repos where you trust the contributors.
214
+
215
+ ## Disclaimer
216
+
217
+ > This project is **100% vibe-coded** — written entirely through AI-assisted development with Claude Code. Why is that fine? It's a read-only tool that posts PR comments. The worst it can do is post a bad review.
218
+
219
+ ## License
220
+
221
+ MIT