lintobot 0.0.0-stage → 0.1.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 +251 -2
  3. package/dist/cli.js +1985 -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,252 @@
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
+ 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.
4
+
5
+ ```
6
+ lib/helper/Playwright.js (5025 lines, 17 parts)
7
+ Executes JavaScript inside the browser page, reads or writes files on disk
8
+ ❌ no deprecated methods 99% lines 3229–4048
9
+ ⚠️ no direct CDP access 82% lines 3901–4480
10
+ ✅ no secret values exposed 5–6%
11
+
12
+ lib/helper/FileSystem.js
13
+ Reads or writes files on disk
14
+ ✅ 5 rules
15
+
16
+ 2 files · 1 error · 1 warning · 3 notes · 18 calls · 66k tokens · $0.0028 · 1.8s
17
+ ```
18
+
19
+ ❌ and ⚠️ are rules that look broken, ✅ rules that hold. The plain line under a file name lists observations that are true of it.
20
+
21
+ > Early version. Yes/no rules, formulas, file facts, context and large-file handling work. Composition rules, diff mode and calibration are specified in [SPEC.md](SPEC.md) but not built yet.
22
+
23
+ ## Install
24
+
25
+ Requires Node 22+ or Bun.
26
+
27
+ ```bash
28
+ npm install -g lintobot # or run once: npx lintobot
29
+ ```
30
+
31
+ Pick a model and give the provider's key, in the environment or in a `.env` file where you run it:
32
+
33
+ ```bash
34
+ LINTOBOT_MODEL=openrouter/typesafe/jev-1.14
35
+ OPENROUTER_API_KEY=...
36
+ ```
37
+
38
+ Then, in any project:
39
+
40
+ ```bash
41
+ lintobot init # writes a starter lintobot.yml for this folder
42
+ lintobot src/ # or: built-in rules, no config needed
43
+ lintobot src/ --dry-run # see what would be sent and the exact questions; nothing is sent
44
+ ```
45
+
46
+ ## Models
47
+
48
+ `LINTOBOT_MODEL` is `<provider>/<model id>`:
49
+
50
+ | `LINTOBOT_MODEL` | Key |
51
+ |---|---|
52
+ | `openrouter/typesafe/jev-1.14` | `OPENROUTER_API_KEY` |
53
+ | `aimlapi/typesafe/jev-1.14` | `AIMLAPI_API_KEY` |
54
+ | `typesafe/jev-latest` | `TYPESAFE_API_KEY` and `TYPESAFE_BASE_URL` |
55
+ | `gateway/typesafe-ai/jev` | `AI_GATEWAY_API_KEY` |
56
+
57
+ Only OpenRouter has been run against the real service so far. `LINTOBOT_API_KEY` and `LINTOBOT_BASE_URL` override the provider's defaults.
58
+
59
+ ## Rules
60
+
61
+ `lintobot.yml`:
62
+
63
+ ```yaml
64
+ model: openrouter/typesafe/jev-1.14
65
+
66
+ files:
67
+ - pattern: "src/**/*.js"
68
+ rules:
69
+ - "file is focused on a single thing":
70
+ whole: true
71
+ - "no magic numbers"
72
+ - "no secret values exposed":
73
+ error: 0.6
74
+ - "comments explain intent and not the code":
75
+ $if!: file.comment_lines > 5
76
+ - "no direct database access":
77
+ ask: Does the code open a database connection or run a query itself?
78
+ criteria:
79
+ yes: Calls a driver or builds SQL in this file
80
+ no: Goes through a repository or service
81
+ - "file is too long":
82
+ error!: file.lines > 800
83
+ ```
84
+
85
+ A rule is a sentence that must hold. The result is the confidence, 0 to 1, that it is **broken**.
86
+
87
+ | Option | Meaning |
88
+ |---|---|
89
+ | `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 |
90
+ | `$if!` | Formula deciding whether the rule applies to a file; reads only `file` |
91
+ | `except` | A glob or a list of globs: files the rule does not apply to |
92
+ | `ask` | The question to send instead of the generated one |
93
+ | `criteria` | `yes:` / `no:` descriptions of what counts |
94
+ | `whole: true` | The rule is about the file as a whole: asked once, no area reported |
95
+ | `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` |
96
+ | `id` | Short name, printed and usable with `--rule` |
97
+ | `context` | Extra material for this rule (below) |
98
+
99
+ **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.
100
+
101
+ `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.
102
+
103
+ ### Exceptions
104
+
105
+ `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.
106
+
107
+ ```yaml
108
+ files:
109
+ - pattern: "app/controllers/**/*.rb"
110
+ except: "app/controllers/legacy/**"
111
+ rules:
112
+ - "no magic numbers":
113
+ except: ["app/controllers/api/**", "**/*_concern.rb"]
114
+ ```
115
+
116
+ ### Info
117
+
118
+ 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.
119
+
120
+ ```yaml
121
+ files:
122
+ - pattern: "src/**/*.ts"
123
+ rules:
124
+ - "no magic numbers"
125
+ info:
126
+ - "has I/O interactions"
127
+ - "talks to the database":
128
+ show: 0.8
129
+ ask: Does the code run a database query or open a connection?
130
+ - "is a large module":
131
+ show!: file.lines > 400
132
+ ```
133
+
134
+ 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`.
135
+
136
+ 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.
137
+
138
+ ### Formulas
139
+
140
+ 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:
141
+
142
+ ```yaml
143
+ - "no long tangled file":
144
+ error!: confidence > 0.8 and file.lines > 300
145
+ - "controllers do not import the database layer":
146
+ error!: some i in file.imports satisfies starts with(i, "../db")
147
+ ```
148
+
149
+ `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.
150
+
151
+ ### Context
152
+
153
+ Named extra material sent beside the code, at the top of the config, on a `files` entry, or on one rule:
154
+
155
+ ```yaml
156
+ context:
157
+ style!file: docs/conventions.md
158
+ files:
159
+ - pattern: "lib/helper/*.js"
160
+ context:
161
+ recent!sh: git log -5 --format=%s -- "$FILE"
162
+ rules:
163
+ - "every public command is documented in the `docs` section":
164
+ context:
165
+ docs!file: docs/helpers/$STEM.md
166
+ ```
167
+
168
+ `!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.
169
+
170
+ ### Large files
171
+
172
+ 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:
173
+
174
+ ```yaml
175
+ parts:
176
+ max_lines: 200
177
+ files:
178
+ - pattern: "app/controllers/api/**_controller.rb"
179
+ max_lines: 600
180
+ rules:
181
+ - "thin controller"
182
+ - "no direct SQL":
183
+ max_lines: 150
184
+ ```
185
+
186
+ 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.
187
+
188
+ ## Without a config
189
+
190
+ ```bash
191
+ LINTOBOT_RULES="no magic numbers; no secret values exposed" lintobot src/
192
+ LINTOBOT_INFO="reads or writes files on disk; talks to the network" lintobot src/
193
+ ```
194
+
195
+ 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.
196
+
197
+ Other variables: `LINTOBOT_ERROR`, `LINTOBOT_WARNING`, `LINTOBOT_PART_LINES`, `LINTOBOT_FORMAT`, `LINTOBOT_CONCURRENCY`, `LINTOBOT_CACHE_DIR`.
198
+
199
+ ## Command line
200
+
201
+ ```
202
+ lintobot [files...] files, folders or globs; everything in lintobot.yml when omitted
203
+ --format pretty|json|jsonl pretty on a terminal, jsonl when piped
204
+ -o, --output <file>
205
+ --files <path> relative to the project; repeatable
206
+ --rule <id or sentence> a rule or an info item; repeatable
207
+ --dry-run
208
+ --quiet problems only
209
+ --no-cache answers are cached in .lintobot/cache/
210
+ --no-shell
211
+ --concurrency <n>
212
+ -c, --config <path>
213
+ --max-warnings <n>
214
+
215
+ lintobot init [--force] write a starter lintobot.yml into the current folder
216
+ lintobot skill [name] [--install] print an agent skill (lintobot, linto-lint), or write them to .claude/skills/
217
+ ```
218
+
219
+ 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.
220
+
221
+ ```bash
222
+ lintobot app/controllers # inside the project: only that folder
223
+ lintobot path/to/project/app/controllers # from anywhere: same, config found above it
224
+ lintobot path/to/project # the whole project
225
+ lintobot path/to/project --files app/controllers # paths relative to the project
226
+ lintobot -c path/to/other-config.yml # a config with another name
227
+ ```
228
+
229
+ Naming a folder or file narrows the run to the files in it that the config's patterns match.
230
+
231
+ Exit codes: `0` clean · `1` errors · `2` bad usage or config · `3` model unreachable or checks skipped.
232
+
233
+ ## What to expect from the model
234
+
235
+ - It returns probabilities only: no explanation, no line. The area of a large file is the closest it gets.
236
+ - Answers are stable between runs (a few points) but 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.
237
+ - Code is sent to the provider you chose. `--dry-run` lists exactly which files.
238
+
239
+ ## Development
240
+
241
+ ```bash
242
+ bun install
243
+ ./bin/lintobot # run from source
244
+ bun test
245
+ bun run build # writes dist/cli.js for Node
246
+ bunosh bench:clone # CodeceptJS and the Testomat.io reporter into benchmarks/repos
247
+ bunosh probe <file> # five questions about one file, raw probabilities
248
+ ```
249
+
250
+ ### Releasing
251
+
252
+ 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 (a pre-release goes to the `next` tag). It needs an `NPM_TOKEN` secret in the repository.