diff --git a/.claude/plugins/code-review-tea/README.md b/.claude/plugins/code-review-tea/README.md new file mode 100644 index 0000000..a27b7fb --- /dev/null +++ b/.claude/plugins/code-review-tea/README.md @@ -0,0 +1,55 @@ +# code-review-tea + +Project-local fork of Anthropic's `code-review` plugin, adapted from the GitHub CLI (`gh`) to the Gitea CLI (`tea`). + +## Credit + +This plugin is a fork of **Anthropic's `code-review` plugin** (author: **Boris Cherny**, `boris@anthropic.com`), from the `claude-plugins-official` marketplace. The upstream plugin is GitHub/`gh`-only. All credit for the review design — the 5 parallel specialized agents, confidence-based scoring, and false-positive filtering — belongs to the original. This fork changes only the Gitea contact points. + +## Why a fork + +Vigilar is hosted on a self-hosted Gitea instance (`git.adlee.work`), not GitHub. The upstream `code-review` plugin is hard-wired to `gh` (its `allowed-tools`, PR-fetching, and comment-posting all call `gh`), so it cannot run against this repo as-is. This fork substitutes the five `gh` contact points with `tea` equivalents and changes code-link URLs from GitHub's `blob/SHA/path#L` format to Gitea's `src/commit/SHA/path#L` format. + +## Usage + +On a branch with an open Gitea pull request against `main`: + + /code-review-tea:code-review + +Claude will: +- Verify the PR is reviewable (skip closed/draft/trivial/already-reviewed) +- Gather relevant CLAUDE.md files +- Summarize the change +- Launch 5 parallel review agents (CLAUDE.md compliance, bug scan, git-history context, prior-PR comments, in-code-comment compliance) +- Score each finding 0–100 for confidence +- Filter to findings ≥80 +- Post a single review comment back to the Gitea PR via `tea api` + +## Requirements + +- `tea` CLI (v0.14.1+) installed and logged in as `alee` against `https://git.adlee.work` +- The `alee` login need NOT be the default — the command passes `--remote origin` to resolve context +- An open Gitea pull request to review + +## Load (this plugin is NOT auto-discovered) + +A plugin placed in `/.claude/plugins//` is not auto-discovered by Claude Code. Load it explicitly: + + # per-session (recommended): + claude --plugin-dir .claude/plugins/code-review-tea + + # persistent, user-scope (across all your projects): + claude plugin init code-review-tea # installs to ~/.claude/skills/code-review-tea/ + +## Differences from upstream + +| Area | Upstream (GitHub) | This fork (Gitea) | +|---|---|---| +| CLI | `gh` | `tea` | +| PR metadata | `gh pr view` | `tea pulls --fields ... -o json` | +| Diff | `gh pr diff` | `git diff origin/...origin/` (local; `tea pulls --fields diff` returns empty in 0.14.1) | +| Comment post | `gh pr comment --body` | `tea api /repos/{owner}/{repo}/issues//comments -F body=@-` (`-F` typed field reads stdin; `/repos/` prefix required) | +| Code link | `github.com/o/r/blob/SHA/path#L` | `git.adlee.work/alee/vigilar/src/commit/SHA/path#L` (SHA must be remote-present) | +| Inline line comments | (upstream posts one summary comment) | NOT attempted — single summary comment only (Gitea inline-comment API needs `tea api` review endpoints; out of scope) | + +See `commands/RESOLVED_INVOCATION.md` for the verified `tea` calls. diff --git a/.claude/plugins/code-review-tea/commands/RESOLVED_INVOCATION.md b/.claude/plugins/code-review-tea/commands/RESOLVED_INVOCATION.md new file mode 100644 index 0000000..7ad5483 --- /dev/null +++ b/.claude/plugins/code-review-tea/commands/RESOLVED_INVOCATION.md @@ -0,0 +1,26 @@ +# Resolved tea post-back invocation (verified via Task 2 smoke run) + +Gitea comment posting that survives large multi-line Markdown bodies: + + tea api --remote origin "/repos/{owner}/{repo}/issues//comments" -F body=@- # body via stdin [VERIFIED] + # fallback: -F body=@/tmp/review-tea-body.md # body via file [VERIFIED] + +CRITICAL: use `-F` (typed field), NOT `-f`. `-f key=@file` posts the literal string `@file`; +only `-F key=@file` / `-F key=@-` reads the file/stdin. The endpoint MUST include the `/repos/` +prefix: `/repos/{owner}/{repo}/issues//comments` (without /repos/ it 404s). `tea api` already +prints JSON to stdout — do NOT pass `-o json` (that writes the body to a file named `json`). + +Code link format (verified to render / resolve to HTTP 200 when SHA is remote-present): + https://git.adlee.work/alee/vigilar/src/commit//#L-L # path segment src/commit [VERIFIED] + +Eligibility metadata fetch: + tea pulls --remote origin --fields index,state,draft,title,mergeable,base,head,body -o json + # NOTE: tea v0.14.1 returns empty `diff`/`patch` fields even when requested — do not rely on them. + +Diff source (preferred, local — the reliable source in this tea build): + git diff origin/...origin/ # base/head come from the PR JSON's base/head fields + +Already-reviewed check: + tea pulls review-comments --remote origin -o json # scan body for "### Code review" marker + +Login context: the `alee` tea login is NOT default (tea login list shows default=false). [VERIFIED: --remote origin resolves context; --login alee fallback not needed] diff --git a/CLAUDE.md b/CLAUDE.md index 9c87547..049668d 100644 --- a/CLAUDE.md +++ b/CLAUDE.md @@ -37,3 +37,6 @@ DIY offline-first home security system. Python 3.11+, Flask + Bootstrap 5 dark t - `vigilar config validate` — check config - `pytest` — run tests - `ruff check vigilar/` — lint + +## Code Review +- `/code-review-tea:code-review` — review the current Gitea PR (project-local fork of Anthropic's code-review plugin, adapted from `gh` to `tea`; credit: Boris Cherny). Load via `claude --plugin-dir .claude/plugins/code-review-tea`. See `.claude/plugins/code-review-tea/README.md`.