@jphutchins/code-review 0.1.0-alpha.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/LICENSE +21 -0
- package/README.md +103 -0
- package/dist/index.js +1627 -0
- package/dist/index.js.map +1 -0
- package/package.json +58 -0
- package/schema/VERSIONING.md +92 -0
- package/schema/findings.schema.json +88 -0
- package/schema/prices.example.json +9 -0
- package/schema/prices.schema.json +54 -0
- package/schema/triage.schema.json +19 -0
- package/templates/comment.eta +80 -0
- package/templates/inline.eta +9 -0
package/LICENSE
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2026 JP Hutchins
|
|
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.
|
package/README.md
ADDED
|
@@ -0,0 +1,103 @@
|
|
|
1
|
+
# code-review
|
|
2
|
+
|
|
3
|
+
Build an **agentic pull-request reviewer out of workflow YAML you own** — no marketplace Action, no
|
|
4
|
+
hosted GitHub App, no SaaS reviewer. A headless coding-agent CLI reviews the PR and emits structured
|
|
5
|
+
findings; a deterministic commenter you control renders and posts the sticky summary and inline
|
|
6
|
+
suggestions. **Claude Code (`claude -p`) is the reference adapter — the same shape fits other agent
|
|
7
|
+
CLIs (e.g. OpenCode) and any Anthropic-compatible model backend.** You own the prompt, the schema,
|
|
8
|
+
the security boundary, and the cost.
|
|
9
|
+
|
|
10
|
+
> **Status: alpha.** The approach is proven — a live review on
|
|
11
|
+
> [camas PR #17](https://github.com/JPHutchins/camas/pull/17#issuecomment-4859543691). This repo is
|
|
12
|
+
> the reusable **spec + schema + CLI + templates**: [SPEC.md](SPEC.md) is normative, the schemas live
|
|
13
|
+
> in [schema/](schema/), and the commenter ships as
|
|
14
|
+
> [`@jphutchins/code-review`](https://www.npmjs.com/package/@jphutchins/code-review).
|
|
15
|
+
|
|
16
|
+
## Why "no Action"
|
|
17
|
+
|
|
18
|
+
| Because there's no Action… | You get |
|
|
19
|
+
| --- | --- |
|
|
20
|
+
| The backend is a CLI + `ANTHROPIC_BASE_URL` + a model env | **Agent- & model-agnostic** — no vendor lock |
|
|
21
|
+
| The prompt, schema, and gate live in your repo | **Transparent & auditable** |
|
|
22
|
+
| You choose token scopes / egress / spend cap | **You own the security boundary** |
|
|
23
|
+
| The orchestration is just a CLI call | **Portable** — GitHub is a thin posting adapter |
|
|
24
|
+
|
|
25
|
+
## The CLI
|
|
26
|
+
|
|
27
|
+
The npm package is the **deterministic commenter** — the presentation and posting layer that no
|
|
28
|
+
model should do, plus the adapter glue between an agent CLI's native output and the spec's abstract
|
|
29
|
+
envelope ([SPEC §6.1](SPEC.md#61-result-envelope)).
|
|
30
|
+
|
|
31
|
+
```sh
|
|
32
|
+
npm install -g @jphutchins/code-review
|
|
33
|
+
# or per invocation:
|
|
34
|
+
npx @jphutchins/code-review <subcommand>
|
|
35
|
+
```
|
|
36
|
+
|
|
37
|
+
| Subcommand | What it does |
|
|
38
|
+
| --- | --- |
|
|
39
|
+
| `post` | Post a complete review (inline comments + sticky summary) from findings + envelope + diff — the one-call path |
|
|
40
|
+
| `gather` | Resolve the PR from the CI head SHA and gather the review inputs (diff with git-diff fallback, PR context, prior bot review, failing-job logs) into the workspace for the agent |
|
|
41
|
+
| `render` | Render the sticky-comment markdown from findings + usage + prices |
|
|
42
|
+
| `inline` | Build the GitHub reviews `comments[]` payload from findings + diff (in-diff validation; strays demote to the summary) |
|
|
43
|
+
| `adapt` | Map a native agent-CLI result envelope onto the abstract SPEC §6.1 envelope |
|
|
44
|
+
| `extract` | Recover findings/triage JSON from a native envelope via the deterministic extraction ladder |
|
|
45
|
+
| `cost` | Recompute USD cost from the envelope's per-model token counts + a price map |
|
|
46
|
+
| `validate` | Validate findings JSON against the published schema |
|
|
47
|
+
| `print-schema` | Print a bundled schema (findings, triage, prices) |
|
|
48
|
+
|
|
49
|
+
Every helper is usable standalone; the reference workflow composes them. The comment templates are
|
|
50
|
+
user-swappable — pass `--template` / `--inline-template` to `post` to override the bundled defaults
|
|
51
|
+
in [templates/](templates/). See [docs/adapters.md](docs/adapters.md) for the adapter contract and
|
|
52
|
+
`code-review <subcommand> --help` for flags.
|
|
53
|
+
|
|
54
|
+
## Quickstart
|
|
55
|
+
|
|
56
|
+
1. Copy [examples/workflows/review.yaml](examples/workflows/review.yaml) into `.github/workflows/`.
|
|
57
|
+
Your existing CI workflow is untouched — edit the `workflows: ["CI"]` filter to match its `name:`.
|
|
58
|
+
2. Set the `API_BASE_URL` Actions **variable** — your provider's Anthropic-compatible endpoint,
|
|
59
|
+
e.g. `https://api.deepseek.com/anthropic` — and add a repo secret `MODEL_API_KEY`, a **burner
|
|
60
|
+
key with a hard spend cap** (it is exposed to untrusted PR code during the contained review
|
|
61
|
+
window). Both are required: with no endpoint configured the workflow fails loudly rather than
|
|
62
|
+
letting the CLI pick where your key gets sent.
|
|
63
|
+
3. Commit `.github/prices.json` (fork [schema/prices.example.json](schema/prices.example.json) and
|
|
64
|
+
fill in your provider's per-token rates) — without it the cost footer renders **$0**
|
|
65
|
+
([SPEC §6.2](SPEC.md#62-price-map)).
|
|
66
|
+
4. Merge to your default branch first — `workflow_run` only fires from the default branch, so the
|
|
67
|
+
introducing PR won't review itself — then open a test PR.
|
|
68
|
+
5. First run: consider `egress-policy: audit` to discover the real allowlist, then switch to `block`
|
|
69
|
+
([SPEC §8.4](SPEC.md#84-egress-allowlist)).
|
|
70
|
+
|
|
71
|
+
Every model knob is committed step `env` on the workflow's triage and review steps — models,
|
|
72
|
+
efforts, the subagent model, and the tier aliases, right where each is consumed — edited and
|
|
73
|
+
PR-reviewed like the rest of the file ([SPEC §8.5](SPEC.md#85-model-backend-env)). Only the backend
|
|
74
|
+
endpoint is a per-repo **Actions variable** (`API_BASE_URL`, required, no default); pointing it at
|
|
75
|
+
another provider requires adding that provider's API host to the workflow's egress allowlist in the
|
|
76
|
+
same reviewed PR.
|
|
77
|
+
|
|
78
|
+
## What's here
|
|
79
|
+
|
|
80
|
+
- **[SPEC.md](SPEC.md)** — the normative, provider-agnostic specification.
|
|
81
|
+
- **[schema/](schema/)** — the findings/triage/prices JSON Schemas + the version policy.
|
|
82
|
+
- **[src/](src/)** — the commenter CLI (published as `@jphutchins/code-review`).
|
|
83
|
+
- **[docs/adapters.md](docs/adapters.md)** — the adapter contract + the Claude Code reference adapter.
|
|
84
|
+
- **[docs/design.md](docs/design.md)** — rationale and history.
|
|
85
|
+
- **[examples/workflows/review.yaml](examples/workflows/review.yaml)** — the copy-paste reference workflow.
|
|
86
|
+
|
|
87
|
+
## License
|
|
88
|
+
|
|
89
|
+
[MIT](LICENSE)
|
|
90
|
+
|
|
91
|
+
## Trademarks
|
|
92
|
+
|
|
93
|
+
"Claude" and "Claude Code" are trademarks of Anthropic, PBC. "OpenCode", "DeepSeek", and "GitHub" are
|
|
94
|
+
trademarks of their respective owners. This project is independent and is **not affiliated with,
|
|
95
|
+
sponsored by, or endorsed by** any of them; their names are used nominatively only, to refer to the
|
|
96
|
+
tools an adapter targets.
|
|
97
|
+
|
|
98
|
+
> [!NOTE]
|
|
99
|
+
> **LLM Disclosure** — this repo's design, spec, schemas, and implementation were authored by
|
|
100
|
+
> Anthropic Claude models (claude-opus-4-8 for the initial design and schema; claude-fable-5 with
|
|
101
|
+
> Opus/Sonnet subagents for the spec tightening and implementation) on behalf of
|
|
102
|
+
> [@JPHutchins](https://github.com/JPHutchins), who prototyped and proved the approach in
|
|
103
|
+
> [camas](https://github.com/JPHutchins/camas) and directs and reviews the work.
|