yolont 0.1.0 → 0.2.0

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 CHANGED
@@ -1,84 +1,180 @@
1
1
  # Yolont
2
2
 
3
- LLM pull request reviewer for **GitHub and GitLab**. Yolont reviews an MR/PR against your
4
- team's conventions and sensitive code zones, gives it a 0–100 score, and posts one comment.
5
- It's informational by default: it posts a score and blocks nothing unless you turn gating on.
3
+ **PR reviews that look twice.** An LLM reviewer for GitHub and GitLab that knows *your* team's
4
+ rules, looks harder where mistakes hurt, scores every MR/PR 0–100, and learns when you tell it
5
+ it's wrong.
6
6
 
7
- 📖 **[The full guide](docs/GUIDE.md)**: every feature, every command, and why it's called Yolont.
7
+ ```bash
8
+ cd ~/code/your-project
9
+ npx yolont
10
+ ```
8
11
 
9
- Two ways to run it:
12
+ The first run offers to install the `yolont` command (`npm install -g`), so from then on
13
+ it's just:
10
14
 
11
- - **On your machine:** the `yolont` CLI. A guided setup asks for the git host, the LLM,
12
- conventions, zones and weights. Then you review an open PR interactively: keep, edit or
13
- drop each finding before anything is posted. A local panel shows reviews, authors, memory
14
- and settings.
15
- - **In CI:** a GitHub Action or a GitLab CI job posts the score on every MR/PR.
15
+ ```bash
16
+ yolont
17
+ ```
16
18
 
17
- ## How a review works
19
+ You need Node 22.13+ and [gitleaks](https://github.com/gitleaks/gitleaks#installing). No config
20
+ files to write: the wizard asks for what it needs.
18
21
 
19
- 1. Loads the rubric, conventions and zones. A repo's `.yolont/` folder wins over your user
20
- settings, which win over the built-ins.
21
- 2. Takes the diff from local `git diff`, falling back to the forge API.
22
- 3. Runs `gitleaks` on the diff. A hit means the diff is never sent to an LLM and the job
23
- fails, whatever `gate` says.
24
- 4. Reads this pipeline's own job results (lint, tests, coverage) for the deterministic
25
- categories. It never re-runs your build.
26
- 5. Makes one LLM call for all LLM categories. The score is recomputed from the findings, so
27
- the model's own number is only advisory.
28
- 6. Posts (or edits) one comment with the score, a per-category breakdown, the top findings,
29
- touched zones and the author's trend.
22
+ *(YOLO + n't = **yolont**: you only live once, so don't merge like it.
23
+ [The long story](docs/GUIDE.md#0-why-yolont).)*
30
24
 
31
- ## Quickstart: local CLI
25
+ ---
32
26
 
33
- Needs Node 22.13+ and [gitleaks](https://github.com/gitleaks/gitleaks#installing) on `PATH`.
27
+ ## What it looks like
34
28
 
35
- ```bash
36
- cd ~/code/your-project # any checkout, or anywhere and paste the repo address
37
- npx yolont # no install: guided setup, then pick an open MR/PR to review
38
- npx yolont panel # local web panel (prints a URL with a one-time token)
29
+ ### 1. The wizard sets you up
39
30
 
40
- npm install -g yolont # or install it, then drop the `npx`
41
- yolont
31
+ ```
32
+ ██╗ ██╗ ██████╗ ██╗ ██████╗ ███╗ ██╗████████╗
33
+ ╚██╗ ██╔╝██╔═══██╗██║ ██╔═══██╗████╗ ██║╚══██╔══╝
34
+ ╚████╔╝ ██║ ██║██║ ██║ ██║██╔██╗ ██║ ██║
35
+ ╚██╔╝ ██║ ██║██║ ██║ ██║██║╚██╗██║ ██║
36
+ ██║ ╚██████╔╝███████╗╚██████╔╝██║ ╚████║ ██║
37
+ ╚═╝ ╚═════╝ ╚══════╝ ╚═════╝ ╚═╝ ╚═══╝ ╚═╝
38
+ PR reviews that look twice · Esc = back · Ctrl-C = quit
39
+
40
+ ╭─ Yolont ─────────────────────────────────────────────╮
41
+ │ Project acme/shop · github.com │
42
+ │ LLM anthropic · claude-sonnet-5-5 │
43
+ │ Memory frontend · 2 to send │
44
+ │ Change type Label │
45
+ ╰──────────────────────────────────────────────────────╯
46
+
47
+ ◆ acme/shop · github.com
48
+ │ ● Review an open MR/PR
49
+ │ ○ ✓ Git host & token
50
+ │ ○ ✓ LLM
51
+ │ ○ ✓ Conventions
52
+ │ ○ ✓ Zones
53
+ │ ○ ✓ Scoring weights
54
+ │ ○ Memory repo · frontend · 2 to send
55
+ │ ○ Change type: Label
56
+ │ ○ Remove saved…
57
+ │ ○ Exit
42
58
  ```
43
59
 
44
- `yolont --help` lists every command. [local/README.md](local/README.md) covers the
45
- wizard, where settings live, and the panel.
60
+ On the first run it walks you through: **git host + token** (checked against the project),
61
+ **LLM** (a real test call before anything is saved), **conventions** (drafted from your repo,
62
+ and you approve them), **zones** and **weights** (optional). After that, plain `yolont`
63
+ goes straight to this menu.
46
64
 
47
- ## Quickstart: GitHub Action
65
+ ### 2. It reviews
48
66
 
49
- 1. Add one LLM key as a repository secret (Settings → Secrets and variables → Actions),
50
- e.g. `ANTHROPIC_API_KEY`.
51
- 2. Copy [templates/yolont.github-workflow.yml](templates/yolont.github-workflow.yml) to
52
- `.github/workflows/yolont.yml` and set `uses:` to where this repo lives.
53
- 3. Optionally commit `.yolont/conventions.md`, `.yolont/zones.yaml` and `.yolont/rubric.yml`
54
- (the CLI's setup writes them for you to copy). Without them Yolont uses its built-in
55
- rubric and generic conventions, and zones are off.
67
+ ```
68
+ ◇ Anything specific to emphasize for this review?
69
+ │ the retry logic in the payment client
70
+
71
+ Score: 74/100 (fail vs threshold 80)
72
+ conventions 85/100 ok
73
+ - [minor] src/pay/client.ts:12 Imports from '../../lib' — conventions say use the '@/lib' alias
74
+ maintainability 70/100 ok
75
+ - [major] src/pay/retry.ts:41 Retries a non-idempotent POST; a timeout can charge the card twice
76
+ suggestion: send an Idempotency-Key header, or retry only on connection errors
77
+ ai_authenticity 80/100 ok
78
+ - [minor] src/pay/retry.ts:8 try/catch around a pure function that can't throw
79
+ security 100/100 ok
80
+ pr_hygiene 90/100 ok
81
+
82
+ Zones touched:
83
+ [red] payments — impact high: retry change runs on every checkout
84
+ src/pay/retry.ts, src/pay/client.ts
85
+ ```
56
86
 
57
- The job token posts the comment. The workflow needs these permissions:
87
+ gitleaks scans the diff first. If it finds a secret, nothing is sent to the LLM.
58
88
 
59
- | Permission | Why |
60
- |---|---|
61
- | `contents: read` | checkout |
62
- | `pull-requests: write` | read the PR, post inline threads |
63
- | `issues: write` | the summary comment and the `llm-reviewed` label use the issues API |
64
- | `actions: read` | job results (lint, tests) feed the score |
89
+ ### 3. You get the last word
90
+
91
+ ```
92
+ ◆ Agree with the computed score (74/100)?
93
+ │ No
94
+ ◆ Which should be corrected?
95
+ │ ◼ ai_authenticity (80/100)
96
+ ◆ [ai_authenticity] Corrected score (was 80, Enter to keep)
97
+ │ 95
98
+ ◆ [ai_authenticity] Why? (becomes memory context for future reviews of this author)
99
+ │ The try/catch is our logging convention for this module, it's intentional.
100
+ ◆ Post this score as a comment on PR #42?
101
+ │ Yes
102
+ ```
103
+
104
+ That "why" is remembered. Corrections go into this author's next reviews, and
105
+ `yolont distill` turns a batch of them into lasting lessons. Nothing is posted unless you say
106
+ yes.
107
+
108
+ ### 4. The comment on the PR
109
+
110
+ > ## 🟡 PR Score: 77 / 100
111
+ > **Type:** Bug fix (title prefix "fix:")
112
+ >
113
+ > | Category | Score | Weight | Status |
114
+ > |---|---|---|---|
115
+ > | conventions | 85/100 | 30% | ok |
116
+ > | maintainability | 70/100 | 30% | ok |
117
+ > | ai_authenticity | 95/100 | 20% | ok |
118
+ > | security | 100/100 | 12% | ok |
119
+ > | pr_hygiene | 90/100 | 8% | ok |
120
+ >
121
+ > ### Top findings
122
+ > - **major** `src/pay/retry.ts:41`: Retries a non-idempotent POST; a timeout can charge the card twice
123
+ >
124
+ > ### Author trend
125
+ > Last 5 score(s): 68, 71, 75, 74, 77.
126
+
127
+ Findings with a file and line also go up as inline threads, so the author can reply right on
128
+ the code. Later runs edit this comment instead of adding new ones.
129
+
130
+ ### 5. The panel
65
131
 
66
- **Fork PRs:** GitHub gives `pull_request` runs from forks no secrets and a read-only token,
67
- so Yolont skips them with a message. On a public repo that takes fork PRs, use
68
- `on: pull_request_target` instead (commented out in the template). Yolont then reads the PR
69
- only through the API and never runs its code. Keep the default `actions/checkout`, which
70
- checks out your base branch, and the rubric and conventions come from your branch, not from
71
- the PR. Very large PRs may exceed GitHub's diff API limit.
132
+ ```bash
133
+ yolont panel # → http://127.0.0.1:4173/?token=… (local only, new token every start)
134
+ ```
135
+
136
+ All your reviews, per-author trends, memory, findings, a conventions editor, and weight sliders
137
+ that replay your last 20 reviews with the new weights before you save.
138
+
139
+ ---
72
140
 
73
- Only jobs in the same workflow are visible to the score. Put lint and tests in that
74
- workflow and have the Yolont job `needs:` them.
141
+ ## Why use it
75
142
 
76
- ## Quickstart: GitLab CI
143
+ - **Your rules, not generic advice.** Conventions are drafted from your own repo, edited by
144
+ you, and checked rule by rule, including where files live.
145
+ - **Looks harder where it hurts.** Zones mark what runs on every request or can't be undone
146
+ (middleware, migrations, root layouts), and the review gets extra checks for those parts.
147
+ - **The score is math, not vibes.** It's recomputed from the findings and scaled to the
148
+ change's size, so the LLM can't wave a PR through.
149
+ - **It learns.** Corrections become memory per author and per project. Share that memory with
150
+ your team through a git repo, using merge requests.
151
+ - **It knows a refactor from a feature.** A refactor that changes behavior gets flagged. A bug
152
+ fix without a regression test gets asked for one.
153
+ - **Fails closed.** No gitleaks, no LLM call. Tokens are only ever sent to their own host.
154
+ No telemetry.
77
155
 
78
- 1. Create a project or group access token: scope `api`, role Developer.
79
- 2. Add CI/CD variables (masked and protected): `GITLAB_API_TOKEN`, plus one LLM key.
80
- 3. Build and push the image from this repo's `Dockerfile` (its own `.gitlab-ci.yml` does it
81
- on the default branch), then include the job:
156
+ ---
157
+
158
+ ## In CI (2 minutes)
159
+
160
+ **GitHub Actions**: add an `ANTHROPIC_API_KEY` secret, then
161
+ [`templates/yolont.github-workflow.yml`](templates/yolont.github-workflow.yml) →
162
+ `.github/workflows/yolont.yml`:
163
+
164
+ ```yaml
165
+ permissions: { contents: read, pull-requests: write, issues: write, actions: read }
166
+ jobs:
167
+ yolont:
168
+ runs-on: ubuntu-latest
169
+ steps:
170
+ - uses: actions/checkout@v4
171
+ - uses: srcgrp/yolont@main # pin a tag or sha
172
+ env:
173
+ ANTHROPIC_API_KEY: ${{ secrets.ANTHROPIC_API_KEY }}
174
+ ```
175
+
176
+ **GitLab CI**: add `GITLAB_API_TOKEN` (project/group token, `api`) and one LLM key as CI/CD
177
+ variables, build the image from this repo's `Dockerfile`, then:
82
178
 
83
179
  ```yaml
84
180
  include:
@@ -87,99 +183,43 @@ include:
87
183
  file: 'templates/yolont.gitlab-ci.yml'
88
184
  ```
89
185
 
90
- A group token sees the author's MRs across every project in the group, so author history
91
- spans repos. A project token only sees that one project. Don't use a personal token.
92
-
93
- `templates/pr-score.gitlab-ci.yml`, the `pr-score` image and `/opt/pr-score/index.js` still
94
- work for existing pipelines.
95
-
96
- ## Tokens
186
+ It's informational by default: it posts a score and blocks nothing until you
187
+ [turn on gating](docs/GUIDE.md#gating). Fork PRs, permissions and self-hosted GitLab are covered
188
+ in the guide: [GitHub](docs/GUIDE.md#13-ci-github-actions) · [GitLab](docs/GUIDE.md#14-ci-gitlab).
97
189
 
98
- | Where | Token | Minimum |
99
- |---|---|---|
100
- | GitHub CLI | PAT | classic `repo`, or fine-grained: Pull requests + Issues read & write, Contents + Actions read |
101
- | GitHub Action | job token (automatic) | permissions table above |
102
- | GitLab CLI | personal access token | `api` |
103
- | GitLab CI | project/group access token | `api`, role Developer |
190
+ ---
104
191
 
105
- The CLI stores tokens in the OS keychain (a `0600` file where there is none). Each token is
106
- only ever sent to the host it was saved for.
192
+ ## Everything else
107
193
 
108
- ## LLM providers (CI)
194
+ 📖 **[The Yolont Guide](docs/GUIDE.md)** has the full story, and a few jokes.
109
195
 
110
- Set one of these. The first one set wins:
111
-
112
- | Variable | Notes |
196
+ | I want to… | Read |
113
197
  |---|---|
114
- | `ANTHROPIC_API_KEY` (+ `ANTHROPIC_MODEL`) | Claude API |
115
- | `OPENCODE_ZEN_API_KEY` (+ `OPENCODE_ZEN_MODEL`) | free-tier gateway, key at [opencode.ai/auth](https://opencode.ai/auth) |
116
- | `OPENCODE_ZEN_GO_API_KEY` (+ `OPENCODE_ZEN_GO_MODEL`) | second gateway |
117
- | `OMNI_API_KEY` + `OMNI_BASE_URL` (+ `OMNI_MODEL`) | any OpenAI-compatible gateway |
118
- | `OLLAMA_URL` (+ `OLLAMA_MODEL`) | self-hosted, fully offline |
119
-
120
- Optional: `MINIO_ENDPOINT`, `MINIO_ACCESS_KEY`, `MINIO_SECRET_KEY` and `MINIO_BUCKET` cache
121
- author history. Without them, Yolont rebuilds history from its past comments.
122
-
123
- `YOLONT_CHANGE_TYPE` sets how the change type (feature, bugfix, refactor, performance, tests, docs,
124
- chore, ci, revert, mixed) is used, and it's shown on the comment:
125
- - `label` (default): the review call also names the type. The review is unchanged; no extra cost.
126
- - `steer`: the type is settled first, from the title prefix (`fix:`), branch (`feat/…`) or labels,
127
- else one small extra LLM call, and the review gets that type's checks (a refactor must not
128
- change behavior, a bug fix needs a regression test, …). Scores and weights don't change.
129
- - `off`.
130
-
131
- Locally the same choice is the wizard menu's **Change type**, and you confirm the suggested type
132
- during each review.
133
-
134
- ## Rubric
135
-
136
- `.yolont/rubric.yml` (built-in default: [.pr-reviewer/rubric.yml](.pr-reviewer/rubric.yml)):
137
-
138
- - `threshold`: the passing score.
139
- - `gate`: `false` (the default) only posts. Set it to `true` **and** make the CI job blocking
140
- (`allow_failure: false` on GitLab, a required check on GitHub) to block merges.
141
- - Each category has a `weight` (weights sum to 100) and a `type` (`deterministic` | `llm` |
142
- `hybrid`). Non-LLM categories also have a `source`: `diff_size`, `secrets`, `test_report`,
143
- or `job:<substring>` matched against your job names.
144
-
145
- A category whose source has no data in a run is excluded, and its weight is shared out
146
- among the rest. The comment shows this.
147
-
148
- ## Security notes
149
-
150
- - `gitleaks` runs before any LLM call. If it finds a secret, or can't run, the diff is not
151
- sent.
152
- - Tokens and keys come from CI variables or the keychain and are never logged.
153
- - In CI, `.yolont/` is read from the checked-out code. With `pull_request` (GitHub) or a
154
- GitLab MR pipeline, that's the MR's own code, so an MR can change its own rubric. If you
155
- gate merges, protect `.yolont/` with CODEOWNERS, or use `pull_request_target` on GitHub.
156
- - On GitHub, only comments from a bot or a repo member count as earlier Yolont comments.
157
- Pasting the marker into a comment doesn't fake one.
158
- - The local panel listens on `127.0.0.1` only and needs the per-start token. It never
159
- returns saved secrets.
198
+ | Write or generate conventions | [Conventions](docs/GUIDE.md#6-conventions) |
199
+ | Mark risky parts of the code | [Zones](docs/GUIDE.md#7-zones-where-the-dragons-live) |
200
+ | Change how the score is weighted, or block merges | [Weights and the rubric](docs/GUIDE.md#8-weights-and-the-rubric) |
201
+ | Review a refactor differently from a feature | [Change type](docs/GUIDE.md#9-change-type) |
202
+ | Teach it, and share that with my team | [Memory](docs/GUIDE.md#10-memory-yolont-learns-from-you) · [Memory repos](docs/GUIDE.md#11-memory-repos-share-it-with-your-team) |
203
+ | Use Ollama, OpenRouter or another LLM | [LLM providers](docs/GUIDE.md#15-llm-providers) |
204
+ | Know exactly what leaves my machine | [Security model](docs/GUIDE.md#17-security-model-the-paranoid-chapter) |
205
+ | See every command | [Command reference](docs/GUIDE.md#18-command-reference) |
206
+ | Fix something | [Troubleshooting](docs/GUIDE.md#20-troubleshooting--faq) |
207
+
208
+ ---
160
209
 
161
210
  ## Development
162
211
 
163
212
  ```bash
213
+ git clone https://github.com/srcgrp/yolont.git && cd yolont
164
214
  npm ci
165
- npm run typecheck
166
- npm test # vitest
167
- npm run build # typecheck, then bundle dist/index.js (CI) and dist/cli.js (CLI)
168
- cd local && npx tsx cli.ts # run the CLI from source
215
+ npm test # vitest
216
+ npm run build # typecheck + bundle dist/index.js (CI) and dist/cli.js (CLI)
217
+ cd local && npx tsx cli.ts # run the CLI from source
169
218
  ```
170
219
 
171
- To dry-run the CI entry against a real MR, fill in a copy of `.env.example` and run
172
- `node --env-file=<that file> dist/index.js` from inside the checkout being reviewed.
173
-
174
- On GitLab, the local diff first fetches `CI_MERGE_REQUEST_DIFF_BASE_SHA` directly. This
175
- needs `uploadpack.allowReachableSHA1InWant`, which is on at gitlab.com but often off on
176
- self-hosted instances. Without it, Yolont fetches the target branch at depth 50, so the merge
177
- base must be within that range. If the diff can't be built locally, Yolont uses the API diff.
178
-
179
220
  ## License
180
221
 
181
- Yolont is **source-available** under the [Functional Source License 1.1 (FSL-1.1-ALv2)](LICENSE.md),
182
- not an OSI open-source license. You may use, modify and redistribute it for any purpose
183
- except offering a competing commercial product or service. Internal use at your company,
184
- education and research are all fine. Two years after each version is released, that version
185
- also becomes available under the Apache License 2.0.
222
+ Source-available under the [Functional Source License 1.1 (FSL-1.1-ALv2)](LICENSE.md). Use,
223
+ modify and redistribute it for anything except a competing commercial product or service.
224
+ Internal company use, education and research are all fine. Each version becomes Apache-2.0
225
+ two years after its release.
package/dist/cli.js CHANGED
@@ -2659,6 +2659,8 @@ var ConfigSchema = z5.object({
2659
2659
  sources: z5.array(SourceSchema).optional(),
2660
2660
  /** Wizard look: Nerd Font icons ("nerd") or plain text. Asked once. */
2661
2661
  icons: z5.enum(["nerd", "plain"]).optional(),
2662
+ /** Run through npx: the offer to install the `yolont` command was answered (asked once). */
2663
+ installOffered: z5.boolean().optional(),
2662
2664
  /** Save limit for conventions files (default 300 lines; they go into every review prompt). */
2663
2665
  conventionsMaxLines: z5.number().int().min(20).max(2e3).optional(),
2664
2666
  /** Change type (src/changeType.ts): off, label (named with the review) or steer (settled first, then type-specific checks). */
@@ -5705,6 +5707,7 @@ function originAddress() {
5705
5707
  var gitlabBases2 = () => loadConfig().forges.filter((f) => f.type === "gitlab" && f.url).map(forgeUrl);
5706
5708
  async function runSetup(opts) {
5707
5709
  header("PR reviews that look twice \xB7 Esc = back \xB7 Ctrl-C = quit");
5710
+ await offerInstallOnce();
5708
5711
  await askIconsOnce();
5709
5712
  intro2(opts.review ? "Yolont" : "Yolont setup");
5710
5713
  trackKeys();
@@ -5763,6 +5766,28 @@ async function reviewThenCheckQuit(ctx, mrIid) {
5763
5766
  if (lastKey === "ctrl-c") throw new Cancelled();
5764
5767
  }
5765
5768
  var STEP_ICONS = { forge: "git", llm: "llm", conventions: "conventions", zones: "zones", weights: "weights" };
5769
+ var runningFromNpx = (script = process.argv[1] ?? "") => /[\\/]_npx[\\/]/.test(script);
5770
+ async function offerInstallOnce() {
5771
+ if (!runningFromNpx() || loadConfig().installOffered || !process.stdout.isTTY) return;
5772
+ let version = "latest";
5773
+ try {
5774
+ version = JSON.parse(readFileSync13(new URL("../package.json", import.meta.url), "utf8")).version ?? version;
5775
+ } catch {
5776
+ }
5777
+ const ok = await confirm2({ message: `Install the \`yolont\` command, so next time you just type \`yolont\`? (npm install -g yolont@${version})`, initialValue: true });
5778
+ if (isCancel2(ok)) return;
5779
+ saveConfig({ ...loadConfig(), installOffered: true });
5780
+ if (!ok) {
5781
+ log2.info(pc3.dim("OK. Install it any time with `npm install -g yolont`."));
5782
+ return;
5783
+ }
5784
+ const res = spawnSync("npm", ["install", "-g", `yolont@${version}`], { stdio: "inherit", shell: process.platform === "win32" });
5785
+ if (res.status === 0) log2.success(`Installed. From now on run ${pc3.bold("yolont")} (no npx).`);
5786
+ else
5787
+ log2.warn(
5788
+ `Couldn't install it (often a permissions issue with npm's global folder). Run \`npm install -g yolont\` yourself; for permission errors see https://docs.npmjs.com/resolving-eacces-permissions-errors-when-installing-packages-globally`
5789
+ );
5790
+ }
5766
5791
  async function askIconsOnce() {
5767
5792
  if (loadConfig().icons || !process.stdout.isTTY) return;
5768
5793
  const ok = await confirm2({ message: `Do these look like icons (not boxes or "?")? ${iconSample()}`, initialValue: true });