lintobot 0.0.0-stage → 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.
Files changed (4) hide show
  1. package/LICENSE +21 -0
  2. package/README.md +301 -2
  3. package/dist/cli.js +2022 -0
  4. package/package.json +52 -4
package/LICENSE ADDED
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2026 Testomat.io
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 CHANGED
@@ -1,3 +1,302 @@
1
- # Temporary Holding Version
1
+ # lintobot
2
2
 
3
- This version is a temporary placeholder for this package. An operational version to replace this has been submitted for review and is awaiting a staged release.
3
+ [![npm](https://img.shields.io/npm/v/lintobot.svg)](https://www.npmjs.com/package/lintobot)
4
+
5
+ A code linter whose rules are plain-language sentences answered by a **decision model** (Jev and similar). No AST rules to write: you state what must be true of a file, the model says how sure it is that it isn't.
6
+
7
+ ```
8
+ lib/helper/Playwright.js (5025 lines, 17 parts)
9
+ Executes JavaScript inside the browser page, reads or writes files on disk
10
+ ❌ no deprecated methods 99% lines 3229–4048
11
+ ⚠️ no direct CDP access 82% lines 3901–4480
12
+ ✅ no secret values exposed 5–6%
13
+
14
+ lib/helper/FileSystem.js
15
+ Reads or writes files on disk
16
+ ✅ 5 rules
17
+
18
+ 2 files · 1 error · 1 warning · 3 notes · 18 calls · 66k tokens · $0.0028 · 1.8s
19
+ ```
20
+
21
+ ❌ and ⚠️ are rules that look broken, ✅ rules that hold. The plain line under a file name lists observations that are true of it.
22
+
23
+ ## What it is for
24
+
25
+ `lintobot.yml` is where you describe what good code is for you. Its rules are **intentions**, the code you would like to see, not laws.
26
+
27
+ - **Smarter than a linter, cheaper than an agent.** It can tell whether a comment matches the code under it, whether a function belongs in its file, whether a file is about one thing. It answers in a fraction of the time and cost of a subagent reading the same file.
28
+ - **Signals, not problems.** A finding is advice to look, not a call to action. Hand findings to an agent or a reviewer, who reads the code and decides whether there is anything to fix.
29
+ - **Not deterministic.** The answer is a probability; it can move a few points between runs. Results are not strict and should not be read as proof.
30
+ - **Flexible.** Every rule has its own thresholds. Lower `error` on a rule you want enforced hard, raise it or switch it off on one you only want to hear about. The exit code follows what you set.
31
+ - **Strict rules go to the real linter.** What must hold exactly and can be read from syntax ("all methods are private except perform") is better checked by RuboCop, ESLint or Biome. The `linto-lint` skill finds such rules in `lintobot.yml`, sets them up in the linter and comments them out.
32
+
33
+ Start every code file with a few basic checks and add your own intentions on top:
34
+
35
+ ```yaml
36
+ rules:
37
+ - "no duplicated code"
38
+ - "no magic numbers"
39
+ - "no comments that restate the code"
40
+ ```
41
+
42
+ If the project has a `CLAUDE.md` or `AGENTS.md`, the intentions are already written down. The `lintobot` skill (`lintobot skill --install`) tells an agent to read them and turn every statement about how the code should look into a rule.
43
+
44
+ It pairs well with a coding agent: run it from a hook after the agent edits a file, or on a pull request over the changed files, and give the output to the agent as things to review.
45
+
46
+ ```bash
47
+ lintobot --diff # what changed since the last commit: after an agent's edits
48
+ lintobot --diff origin/main # what this branch changes: on a pull request
49
+ lintobot --staged # what is staged: in a pre-commit hook
50
+ ```
51
+
52
+ Only changed files that the config's patterns match are checked, deleted ones are left out, and no change means no file is checked. See [Changed files only](#changed-files-only).
53
+
54
+ > Early version. Yes/no rules, formulas, file facts, context and large-file handling work. Composition rules, checking only the changed lines of a file, and calibration are specified in [SPEC.md](SPEC.md) but not built yet.
55
+
56
+ ## Install
57
+
58
+ Requires Node 22+ or Bun.
59
+
60
+ ```bash
61
+ npm install -g lintobot # or run once: npx lintobot
62
+ ```
63
+
64
+ Pick a model and give the provider's key, in the environment or in a `.env` file where you run it:
65
+
66
+ ```bash
67
+ LINTOBOT_MODEL=openrouter/typesafe/jev-1.14
68
+ OPENROUTER_API_KEY=...
69
+ ```
70
+
71
+ Then, in any project:
72
+
73
+ ```bash
74
+ lintobot init # writes a starter lintobot.yml for this folder
75
+ lintobot src/ # or: built-in rules, no config needed
76
+ lintobot src/ --dry-run # see what would be sent and the exact questions; nothing is sent
77
+ ```
78
+
79
+ ## Models
80
+
81
+ `LINTOBOT_MODEL` is `<provider>/<model id>`:
82
+
83
+ | `LINTOBOT_MODEL` | Key |
84
+ |---|---|
85
+ | `openrouter/typesafe/jev-1.14` | `OPENROUTER_API_KEY` |
86
+ | `aimlapi/typesafe/jev-1.14` | `AIMLAPI_API_KEY` |
87
+ | `typesafe/jev-latest` | `TYPESAFE_API_KEY` and `TYPESAFE_BASE_URL` |
88
+ | `gateway/typesafe-ai/jev` | `AI_GATEWAY_API_KEY` |
89
+
90
+ Only OpenRouter has been run against the real service so far. `LINTOBOT_API_KEY` and `LINTOBOT_BASE_URL` override the provider's defaults.
91
+
92
+ ## Rules
93
+
94
+ `lintobot.yml`:
95
+
96
+ ```yaml
97
+ model: openrouter/typesafe/jev-1.14
98
+
99
+ files:
100
+ - pattern: "src/**/*.js"
101
+ rules:
102
+ - "file is focused on a single thing":
103
+ whole: true
104
+ - "no magic numbers"
105
+ - "no secret values exposed":
106
+ error: 0.6
107
+ - "comments explain intent and not the code":
108
+ $if!: file.comment_lines > 5
109
+ - "no direct database access":
110
+ ask: Does the code open a database connection or run a query itself?
111
+ criteria:
112
+ yes: Calls a driver or builds SQL in this file
113
+ no: Goes through a repository or service
114
+ - "file is too long":
115
+ error!: file.lines > 800
116
+ ```
117
+
118
+ A rule is a sentence that must hold. The result is the confidence, 0 to 1, that it is **broken**.
119
+
120
+ | Option | Meaning |
121
+ |---|---|
122
+ | `error`, `warning` | A number: threshold on the confidence (defaults 0.9 and 0.7). `false` switches that level off. Or a formula giving true/false |
123
+ | `$if!` | Formula deciding whether the rule applies to a file; reads only `file` |
124
+ | `except` | A glob or a list of globs: files the rule does not apply to |
125
+ | `ask` | The question to send instead of the generated one |
126
+ | `criteria` | `yes:` / `no:` descriptions of what counts |
127
+ | `whole: true` | The rule is about the file as a whole: asked once, no area reported |
128
+ | `max_lines` | Part size for this rule alone, 20 or more: it is asked on its own cutting of the file (below). Not with `whole: true` |
129
+ | `id` | Short name, printed and usable with `--rule` |
130
+ | `context` | Extra material for this rule (below) |
131
+
132
+ **Wording matters.** A sentence starting with `no ` is asked as "does the code contain …?"; anything else as "is it true that …?". Questions where *yes* means the thing is present work best; negations and "only" / "always" work poorly. `--dry-run` shows the question as sent.
133
+
134
+ `ask` changes the wording only; the sentence still decides the direction. Under a `no …` sentence a *yes* means broken, under any other sentence a *yes* means fine, so write `ask` to match.
135
+
136
+ ### Exceptions
137
+
138
+ `except` takes a glob or a list of globs, relative to the config's folder like `pattern`. On a `files` entry, matching files are not part of the entry: none of its rules, context or settings apply to them. On a rule, only that rule skips them. Both are settled before the model is asked.
139
+
140
+ ```yaml
141
+ files:
142
+ - pattern: "app/controllers/**/*.rb"
143
+ except: "app/controllers/legacy/**"
144
+ rules:
145
+ - "no magic numbers":
146
+ except: ["app/controllers/api/**", "**/*_concern.rb"]
147
+ ```
148
+
149
+ ### Info
150
+
151
+ Observations about a file, in an `info:` list beside `rules:`. Nothing is wrong when one is true: all that are true of a file are printed as one dim sentence under its name, so you can see what kind of file this is, and it never changes the exit code.
152
+
153
+ ```yaml
154
+ files:
155
+ - pattern: "src/**/*.ts"
156
+ rules:
157
+ - "no magic numbers"
158
+ info:
159
+ - "has I/O interactions"
160
+ - "talks to the database":
161
+ show: 0.8
162
+ ask: Does the code run a database query or open a connection?
163
+ - "is a large module":
164
+ show!: file.lines > 400
165
+ ```
166
+
167
+ The confidence is how sure the model is that the statement is **true**. The statement is asked as "does the code …?" (write it starting with a verb: "launches a job", "calls a service", "is project scoped"); `ask` replaces the question, and a precise one that names what to look for scores highest. A statement is shown when the model is at least 90% sure; change that for all of them with `defaults: { info: 0.8 }` or `LINTOBOT_INFO_CONFIDENCE`. `show` sets one item's own threshold or, as `show!`, a formula over `confidence` and `file`; one that reads only `file` makes no model call. Below the threshold nothing is printed. The other options are those of a rule (`ask`, `criteria`, `$if!`, `except`, `max_lines`, `context`, `whole`, `id`), except `error` and `warning`.
168
+
169
+ Info items are asked in the same calls as the rules. On a file sent in parts the percent is the highest among them; the areas where the statement holds are in the `json` and `jsonl` records. `--quiet` hides them; `json` and `jsonl` have a record `"type":"info"` for every item, with `"shown"` true or false, and the summary counts `notes`. An entry needs `rules` or `info`, either alone is enough.
170
+
171
+ ### Formulas
172
+
173
+ The config is [scripted-yaml](https://www.npmjs.com/package/scripted-yaml): a key ending in `!` holds a FEEL formula. Formulas read `confidence` and the facts of the file:
174
+
175
+ ```yaml
176
+ - "no long tangled file":
177
+ error!: confidence > 0.8 and file.lines > 300
178
+ - "controllers do not import the database layer":
179
+ error!: some i in file.imports satisfies starts with(i, "../db")
180
+ ```
181
+
182
+ `file` has `path`, `dir`, `name`, `ext`, `lines`, `code_lines`, `comment_lines`, `blank_lines`, `longest_line`, `max_depth`, `complexity`, and the lists `imports` and `exports`. A rule whose formulas never read `confidence` makes no model call.
183
+
184
+ ### Context
185
+
186
+ Named extra material sent beside the code, at the top of the config, on a `files` entry, or on one rule:
187
+
188
+ ```yaml
189
+ context:
190
+ style!file: docs/conventions.md
191
+ files:
192
+ - pattern: "lib/helper/*.js"
193
+ context:
194
+ recent!sh: git log -5 --format=%s -- "$FILE"
195
+ rules:
196
+ - "every public command is documented in the `docs` section":
197
+ context:
198
+ docs!file: docs/helpers/$STEM.md
199
+ ```
200
+
201
+ `!file` reads a file, `!sh` runs a command, plain text is sent as is. `$FILE`, `$DIR`, `$STEM`, `$EXT` describe the file being linted. Paths and commands are relative to the config's folder. Each entry is cut to 4,000 bytes. `--no-shell` turns `!sh` off.
202
+
203
+ ### Large files
204
+
205
+ A file over 300 lines is sent in parts and the answers are squashed into one line per check: a failed check shows the line ranges of the parts that failed, a passed one the lowest–highest confidence. Change the size at the top for every file, with `max_lines` on a `files` entry for its rules, or on one rule:
206
+
207
+ ```yaml
208
+ parts:
209
+ max_lines: 200
210
+ files:
211
+ - pattern: "app/controllers/api/**_controller.rb"
212
+ max_lines: 600
213
+ rules:
214
+ - "thin controller"
215
+ - "no direct SQL":
216
+ max_lines: 150
217
+ ```
218
+
219
+ The rule wins over the entry it is written in, the entry over the top level. Smaller parts give finer areas and catch what a large part dilutes, for more calls. Rules with the same size and context share calls; a rule with its own `max_lines` gets its own cutting and its own calls, and its `parts` and areas are counted on that cutting. The file's header shows `(N lines, M parts)` when all its checks share one cutting and `(N lines)` when they differ. `LINTOBOT_PART_LINES` overrides the top-level default only.
220
+
221
+ ## Without a config
222
+
223
+ ```bash
224
+ LINTOBOT_RULES="no magic numbers; no secret values exposed" lintobot src/
225
+ LINTOBOT_INFO="reads or writes files on disk; talks to the network" lintobot src/
226
+ ```
227
+
228
+ With no rules at all, a built-in set applies: single focus, global state, magic numbers, comments, secrets, one export per file, logic easy to follow.
229
+
230
+ Other variables: `LINTOBOT_ERROR`, `LINTOBOT_WARNING`, `LINTOBOT_PART_LINES`, `LINTOBOT_FORMAT`, `LINTOBOT_CONCURRENCY`, `LINTOBOT_CACHE_DIR`.
231
+
232
+ ## Command line
233
+
234
+ ```
235
+ lintobot [files...] files, folders or globs; everything in lintobot.yml when omitted
236
+ --format pretty|json|jsonl pretty on a terminal, jsonl when piped
237
+ -o, --output <file>
238
+ --files <path> relative to the project; repeatable
239
+ --rule <id or sentence> a rule or an info item; repeatable
240
+ --diff [ref] only changed files: since the branch left <ref>, or since the last commit
241
+ --staged only files staged for the next commit
242
+ --dry-run
243
+ --quiet problems only
244
+ --no-cache answers are cached in .lintobot/cache/
245
+ --no-shell
246
+ --concurrency <n>
247
+ -c, --config <path>
248
+ --max-warnings <n>
249
+
250
+ lintobot init [--force] write a starter lintobot.yml into the current folder
251
+ lintobot skill [name] [--install] print an agent skill (lintobot, linto-lint), or write them to .claude/skills/
252
+ ```
253
+
254
+ The folder of the config is the project: patterns, context paths, the cache and reported paths are relative to it, and its `.env` is loaded. The config is found like git finds a repository: the nearest `lintobot.yml` at or above the first path you name, or above where you stand.
255
+
256
+ ```bash
257
+ lintobot app/controllers # inside the project: only that folder
258
+ lintobot path/to/project/app/controllers # from anywhere: same, config found above it
259
+ lintobot path/to/project # the whole project
260
+ lintobot path/to/project --files app/controllers # paths relative to the project
261
+ lintobot -c path/to/other-config.yml # a config with another name
262
+ ```
263
+
264
+ Naming a folder or file narrows the run to the files in it that the config's patterns match.
265
+
266
+ Exit codes: `0` clean · `1` errors · `2` bad usage or config · `3` model unreachable or checks skipped.
267
+
268
+ ### Changed files only
269
+
270
+ ```bash
271
+ lintobot --diff # edited, staged and new untracked files since the last commit
272
+ lintobot --diff origin/main # everything since this branch left origin/main, uncommitted work included
273
+ lintobot --staged # what `git commit` would take
274
+ lintobot app/jobs --diff main # changed files inside one folder
275
+ ```
276
+
277
+ The ref is a branch, tag or commit. The changed files are narrowed by the config's patterns and by any paths you name; deleted files are left out; a whole changed file is checked, not only its changed lines. When nothing changed, nothing is checked and the exit code is `0`. It works from any folder of the repository, and when the project is a subfolder of it.
278
+
279
+ `--diff <ref>` needs the commit where the branch left the ref. A shallow clone does not have it: in GitHub Actions set `fetch-depth: 0` on the checkout step.
280
+
281
+ ## What to expect from the model
282
+
283
+ - It returns probabilities only: no explanation, no line. The area of a large file is the closest it gets.
284
+ - Answers are not deterministic: close between runs (a few points) but not identical, and not calibrated: vague rules such as "no magic numbers" fire on most files until given `criteria`. Treat thresholds as something to tune on your own code.
285
+ - Code is sent to the provider you chose. `--dry-run` lists exactly which files.
286
+
287
+ ## Development
288
+
289
+ ```bash
290
+ bun install
291
+ ./bin/lintobot # run from source
292
+ bun test
293
+ bun run build # writes dist/cli.js for Node
294
+ bunosh bench:clone # CodeceptJS and the Testomat.io reporter into benchmarks/repos
295
+ bunosh probe <file> # five questions about one file, raw probabilities
296
+ ```
297
+
298
+ ### Releasing
299
+
300
+ Publish a GitHub release with a tag such as `v0.2.0`. The `Release to npm` workflow takes the version from the tag, runs the type check, the tests and the build, and publishes to npm with provenance (a pre-release goes to the `next` tag).
301
+
302
+ No npm token is stored. The workflow uses npm trusted publishing: on npmjs.com the package lists this repository and the workflow file `release.yml` as its trusted publisher.