judgelint 0.1.9 → 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.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: a90b0ee415a2b08188fd8141eef3ea4f725e3317a886b487d86ed4d1463c88a4
4
- data.tar.gz: e0c57f2b25e7775a9dcedae5be947de53e8a1bc6ef363d4f07c3a601c8bcfb8d
3
+ metadata.gz: 9e8f4f3282787b4f5f2a371fabb47a8ea697fe19889fae016ba3e9c061c40760
4
+ data.tar.gz: accec3d1659a0de25bc47a426fe20e47df8245ffa034207e6acb90c94cccdfe1
5
5
  SHA512:
6
- metadata.gz: 8849be7a19c2fe4e64304109120856ae8adbd02e3b6cca0894b6cecc2a56be27fa9af3f5e7c805d8c32f6df73e40f42a7b0b2e15e8628c93b938371d605651a8
7
- data.tar.gz: 3df1f283287488314cbb5fb8c2ac21f8b79ead7ed94ce5eb4a2354fd93ca2979f3984a73a24898a4c9a8467c29c2fe698887c52aef7deae2b001e4a1d87d7913
6
+ metadata.gz: 2ebf1cf778ef23c5d132b7fe57383560b562ab9bd82c362d0a8ff8c6c45b33b3f2607e67e611279dc4ff714f25d672ed45dfa8b320738c160fe8825876809e52
7
+ data.tar.gz: dc3e5706f0f5ac53f114d79475696933f94743ffcd10f59cc7ecea2d0ade1e7f02f076286e738dffebb0270c1253da851d57c51fde2add5bff97b77f23edde1c
data/CHANGELOG.md CHANGED
@@ -1,5 +1,38 @@
1
1
  # Changelog
2
2
 
3
+ ## 0.2.0 (2026-10-28)
4
+
5
+ - judgelint is written in Rust now. The gem carries the binary for macOS and
6
+ Linux on arm64 and x86_64. On any other platform the gem says how to build
7
+ it with Cargo; it no longer runs as plain Ruby. There's no Ruby API.
8
+ - It's much faster and smaller than 0.1.10's native binary. On a Mac mini:
9
+
10
+ | Run | 0.1.10 | 0.2.0 |
11
+ |---|---|---|
12
+ | Plan 50,000 files | 9.0 s, 140 MB | 1.2 s, 54 MB |
13
+ | Check 5,000 files, nothing cached | 3.4 s, 82 MB | 0.7 s, 19 MB |
14
+ | Check 5,000 files, all cached | 1.5 s, 56 MB | 0.16 s, 16 MB |
15
+ | Check 50,000 files, nothing cached | 23.8 s, 487 MB | 6.4 s, 75 MB |
16
+
17
+ - Answers are cached in `.judgelint/cache.bin`. The old `cache.json` isn't
18
+ read, so the first run asks again; delete it afterward. The new cache is
19
+ about a quarter of the size.
20
+ - Commands, options, specs, config and output formats are the same. Error
21
+ messages are worded differently.
22
+
23
+ ## 0.1.10 (2026-10-27)
24
+
25
+ - `check` and `test` use far less memory and run faster. Against 0.1.9 on
26
+ a synthetic project, the native binary uses 84–89% less memory, and
27
+ Ruby 73–87% less. Both are 23–51% faster.
28
+ - Files of the same shape share their questions.
29
+ - A planned file is read again when its request is sent instead of being
30
+ kept. A file that changed in between stops the run with an error.
31
+ - The cache stays on disk and is looked up an entry at a time.
32
+ - Connections to the model are kept open between requests.
33
+ - Each glob pattern is walked once.
34
+ - Output and cache files are unchanged.
35
+
3
36
  ## 0.1.9 (2026-10-27)
4
37
 
5
38
  - `check` uses much less memory on large projects. On 50,000 files its
data/README.md CHANGED
@@ -16,9 +16,10 @@ curl -fsSL https://raw.githubusercontent.com/jpcamara/judgelint/main/install.sh
16
16
 
17
17
  The script installs to `~/.local/bin`, or to `$JUDGELINT_INSTALL_DIR`. The
18
18
  binaries are on the [releases page](https://github.com/jpcamara/judgelint/releases)
19
- for macOS and Linux, on arm64 and x86_64. Linux needs glibc 2.35 or newer
20
- (Ubuntu 22.04, Debian 12). `gem install judgelint` works too, and runs as
21
- plain Ruby on Windows.
19
+ for macOS and Linux, on arm64 and x86_64. Linux needs glibc 2.34 or newer
20
+ (Ubuntu 22.04, Debian 12, RHEL 9). `gem install judgelint` installs the same
21
+ binary. Anywhere else, build it with Rust:
22
+ `cargo install --git https://github.com/jpcamara/judgelint`.
22
23
 
23
24
  ## Getting started
24
25
 
@@ -247,7 +248,7 @@ ignore: ["vendor/**"] # files no rule checks, and READMEs that aren't specs
247
248
  max_cost_usd: 1.00 # refuse a run estimated to cost more, unless --yes
248
249
  ```
249
250
 
250
- Every run prints what it cost. Answers are cached in `.judgelint/cache.json`,
251
+ Every run prints what it cost. Answers are cached in `.judgelint/cache.bin`,
251
252
  so a file that hasn't changed costs nothing. Commit the cache to share it.
252
253
  `judgelint --help` lists the flags.
253
254
 
@@ -276,16 +277,13 @@ models:
276
277
 
277
278
  ## Building from source
278
279
 
279
- judgelint is written in Ruby and compiled with
280
- [Spinel](https://github.com/matz/spinel).
280
+ judgelint is written in Rust. The end-to-end tests are in Ruby.
281
281
 
282
282
  ```sh
283
+ cargo build --release # builds target/release/judgelint
283
284
  bundle install
284
- bundle exec rake test
285
- git clone https://github.com/matz/spinel ../spinel && (cd ../spinel && make deps && make)
286
- SPINEL=../spinel/bin/spinel bundle exec rake spinel # builds build/judgelint
287
- SPINEL=../spinel/bin/spinel bundle exec rake test:spinel # runs the tests against the binary
288
- bundle exec rake example # asks Jev about the demo app again
285
+ bundle exec rake test # runs the Rust tests, then the end-to-end tests against the binary
286
+ bundle exec rake example # asks Jev about the demo app again
289
287
  ```
290
288
 
291
289
  ## Credits
data/exe/judgelint CHANGED
@@ -1,14 +1,14 @@
1
1
  #!/usr/bin/env ruby
2
2
  # frozen_string_literal: true
3
3
 
4
- # A platform gem (judgelint-*-arm64-darwin and so on) carries the Spinel-built
5
- # binary in libexec/; run it when it's there. Spinel compiles this file too,
6
- # and drops this branch.
7
- if RUBY_ENGINE != "spinel"
8
- native = File.expand_path("../libexec/judgelint", __dir__)
9
- exec(native, *ARGV) if File.executable?(native)
10
- end
4
+ # The platform gems (judgelint-*-arm64-darwin and so on) carry the binary in
5
+ # libexec/. The plain gem, for every other platform, has none.
6
+ native = File.expand_path("../libexec/judgelint", __dir__)
7
+ exec(native, *ARGV) if File.executable?(native)
11
8
 
12
- require "judgelint"
9
+ abort <<~TEXT
10
+ This judgelint gem has no binary for #{RUBY_PLATFORM}. The binaries are for
11
+ macOS and Linux on arm64 and x86_64. With Rust installed, build it instead:
13
12
 
14
- exit Judgelint::CLI.new(ARGV).run
13
+ cargo install --git https://github.com/jpcamara/judgelint
14
+ TEXT
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: judgelint
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.9
4
+ version: 0.2.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - JP Camara
@@ -12,8 +12,8 @@ dependencies: []
12
12
  description: |
13
13
  judgelint checks code against conventions you write as bullets in a README.
14
14
  It asks a decision model, such as TypeSafe's Jev, whether each file breaks
15
- each bullet, and reports violations with line numbers. On macOS and Linux
16
- the gem includes a native binary.
15
+ each bullet, and reports violations with line numbers. The gem carries
16
+ its native binary for macOS and Linux.
17
17
  email:
18
18
  - johnpcamara@gmail.com
19
19
  executables:
@@ -25,28 +25,6 @@ files:
25
25
  - LICENSE
26
26
  - README.md
27
27
  - exe/judgelint
28
- - lib/judgelint.rb
29
- - lib/judgelint/cache.rb
30
- - lib/judgelint/changes.rb
31
- - lib/judgelint/cli.rb
32
- - lib/judgelint/client.rb
33
- - lib/judgelint/config.rb
34
- - lib/judgelint/errors.rb
35
- - lib/judgelint/glob.rb
36
- - lib/judgelint/paint.rb
37
- - lib/judgelint/pool.rb
38
- - lib/judgelint/protocol.rb
39
- - lib/judgelint/providers.rb
40
- - lib/judgelint/question.rb
41
- - lib/judgelint/reporter.rb
42
- - lib/judgelint/rule.rb
43
- - lib/judgelint/runner.rb
44
- - lib/judgelint/scaffold.rb
45
- - lib/judgelint/source.rb
46
- - lib/judgelint/spec.rb
47
- - lib/judgelint/usage.rb
48
- - lib/judgelint/verdict.rb
49
- - lib/judgelint/version.rb
50
28
  homepage: https://github.com/jpcamara/judgelint
51
29
  licenses:
52
30
  - MIT
@@ -1,53 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- module Judgelint
4
- # Stores each answer under a hash of everything that produced it: the state
5
- # the model saw (path and numbered contents), the question asked of it, and
6
- # the model. Changing any of them is a miss. Safe to share across threads.
7
- class Cache
8
- def initialize(path)
9
- @path = path
10
- @entries = load_entries
11
- @dirty = false
12
- @lock = Mutex.new
13
- end
14
-
15
- def self.key(question_digest, state_digest, model_label)
16
- Digest::SHA256.hexdigest([question_digest, state_digest, model_label].join(":"))
17
- end
18
-
19
- def fetch(key)
20
- @lock.synchronize { @entries[key] }
21
- end
22
-
23
- def store(key, yes_probability)
24
- @lock.synchronize do
25
- @entries[key] = yes_probability
26
- @dirty = true
27
- end
28
- end
29
-
30
- def save
31
- @lock.synchronize do
32
- return unless @path && @dirty
33
-
34
- FileUtils.mkdir_p(File.dirname(@path))
35
- File.write(@path, "#{JSON.pretty_generate(@entries.sort.to_h)}\n")
36
- @dirty = false
37
- end
38
- end
39
-
40
- private
41
-
42
- def load_entries
43
- return {} unless @path && File.exist?(@path)
44
-
45
- data = JSON.parse(File.read(@path))
46
- raise ConfigError, "#{@path} isn't a judgelint cache; delete it to start over" unless data.is_a?(Hash)
47
-
48
- data
49
- rescue JSON::ParserError
50
- raise ConfigError, "#{@path} isn't valid JSON; delete it to start over"
51
- end
52
- end
53
- end
@@ -1,87 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- module Judgelint
4
- # The lines a change touched, from git: everything since the merge base with
5
- # a ref, uncommitted work included. Old code outside the change isn't asked
6
- # about, so it can't block new work.
7
- module Changes
8
- # A branch, tag, or commit (HEAD~1 too), and nothing git could read as an
9
- # option or a range.
10
- REF = %r{\A[A-Za-z0-9][A-Za-z0-9._/~^-]*\z}
11
- HUNK = /\A@@ -\d+(?:,\d+)? \+(\d+)(?:,(\d+))? @@/
12
-
13
- # Returns {path => [changed line numbers]}, or :all for a new file.
14
- def self.since(ref)
15
- check_ref(ref)
16
- base = git("merge-base", ref, "HEAD").strip
17
- changed = parse_diff(git("-c", "core.quotePath=false", "diff", "-U0", "--no-color", "--no-ext-diff",
18
- "--relative", "--diff-filter=d", base))
19
- git("ls-files", "--others", "--exclude-standard").lines.each { |path| changed[path.chomp] = :all }
20
- changed
21
- end
22
-
23
- # CI variables that name a pull request's base branch.
24
- BASE_BRANCH_VARIABLES = %w[
25
- JUDGELINT_BASE_BRANCH GITHUB_BASE_REF CI_MERGE_REQUEST_TARGET_BRANCH_NAME
26
- BUILDKITE_PULL_REQUEST_BASE_BRANCH BITBUCKET_PR_DESTINATION_BRANCH SYSTEM_PULLREQUEST_TARGETBRANCH
27
- ].freeze
28
-
29
- # The pull request's base branch, fetched, as origin/<branch>: from
30
- # JUDGELINT_BASE_BRANCH, then GitHub Actions, GitLab, Buildkite, Bitbucket,
31
- # or Azure Pipelines, then the gh CLI.
32
- def self.pr_base
33
- branch = pr_branch
34
- raise ConfigError, "Couldn't find the pull request's base branch" if branch.empty?
35
-
36
- check_ref(branch)
37
- git("fetch", "--no-tags", "--quiet", "origin", branch)
38
- "origin/#{branch}"
39
- end
40
-
41
- def self.pr_branch
42
- BASE_BRANCH_VARIABLES.each do |name|
43
- # Buildkite sets "false" outside a pull request; Azure names a full ref.
44
- branch = ENV.fetch(name, "").delete_prefix("refs/heads/")
45
- return branch unless branch.empty? || branch == "false"
46
- end
47
- command("gh", "pr", "view", "--json", "baseRefName", "-q", ".baseRefName").strip
48
- end
49
-
50
- def self.parse_diff(diff)
51
- changed = {}
52
- path = nil
53
- diff.each_line do |line|
54
- if line.start_with?("+++ ")
55
- target = line.chomp.delete_prefix("+++ ").delete_suffix("\t")
56
- path = target == "/dev/null" ? nil : target.delete_prefix("b/")
57
- elsif path && (hunk = HUNK.match(line))
58
- start = hunk[1].to_i
59
- count = hunk[2] ? hunk[2].to_i : 1
60
- # A pure deletion marks the line above the gap, so it's still judged.
61
- lines = count.zero? ? [[start, 1].max] : (start...(start + count)).to_a
62
- (changed[path] ||= []).concat(lines)
63
- end
64
- end
65
- changed
66
- end
67
-
68
- def self.check_ref(ref)
69
- return if REF.match?(ref) && !ref.include?("..")
70
-
71
- raise ConfigError, "Not a usable git ref: #{ref}"
72
- end
73
-
74
- def self.git(*args)
75
- command("git", *args)
76
- end
77
-
78
- def self.command(*args)
79
- out, err, status = Open3.capture3(*args)
80
- raise ConfigError, "#{args.first(3).join(' ')} failed: #{err.strip.lines.first.to_s.strip}" unless status.success?
81
-
82
- out
83
- rescue SystemCallError => e
84
- raise ConfigError, "Couldn't run #{args.first}: #{e.message}"
85
- end
86
- end
87
- end
data/lib/judgelint/cli.rb DELETED
@@ -1,251 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- module Judgelint
4
- # Command line entry point. Exit codes: 0 clean, 1 violations (or missed
5
- # examples for `test`), 2 usage or configuration error. Everything that can
6
- # be checked is checked before the first paid request.
7
- class CLI
8
- COMMANDS = %w[check test rules providers init].freeze
9
-
10
- HELP = <<~TEXT
11
- Usage: judgelint [command] [options] [paths...]
12
-
13
- Checks code against the conventions in your specs, like a CONVENTIONS.md
14
- of bullets. For each file and each rule, it asks a decision model (Jev on
15
- TypeSafe by default) whether the code breaks it.
16
-
17
- Commands:
18
- check [paths...] Check the files the specs govern, or these (default).
19
- test [rule ids...] Judge each rule's examples (.judgelint/examples/<id>/pass
20
- and fail) and report what the model gets wrong.
21
- rules List the rules and how many files each governs.
22
- providers List the decision-model providers judgelint knows.
23
- init Write a CONVENTIONS.md to start from, with examples.
24
-
25
- Options:
26
- --base REF Check only what changed since the merge base with REF,
27
- uncommitted work included
28
- --pr --base the pull request's base branch, from CI variables
29
- or the gh CLI
30
- -f, --format FORMAT text, json, github (Actions annotations), or sarif
31
- -m, --model MODEL Ask this model instead of the config's: a provider from
32
- `judgelint providers`, optionally :model (cloudflare:clef)
33
- -c, --config PATH Config file (default .judgelint.yml)
34
- --no-cache Ask the models even when an answer is cached
35
- -y, --yes Run even past max_cost_usd
36
- -v, --version Print the version
37
- -h, --help Print this help
38
-
39
- Exit status: 0 clean, 1 violations or missed examples, 2 usage or config error.
40
- TEXT
41
-
42
- def initialize(argv, out: $stdout, err: $stderr)
43
- @argv = argv.dup
44
- @out = out
45
- @err = err
46
- @format = "text"
47
- @config_path = nil
48
- @base = nil
49
- @pr = false
50
- @yes = false
51
- @overrides = {}
52
- @usage = nil
53
- @no_cache = false
54
- @paint = Paint.for(out)
55
- @err_paint = Paint.for(err)
56
- end
57
-
58
- def run
59
- command = COMMANDS.include?(@argv.first) ? @argv.shift : "check"
60
- @argv = parse_options(@argv)
61
- return 0 if @done
62
-
63
- case command
64
- when "check" then check
65
- when "test" then test
66
- when "rules" then list_rules
67
- when "providers" then list_providers
68
- when "init" then init
69
- end
70
- rescue UsageError => e
71
- @err.puts "#{@err_paint.call('judgelint:', Paint::BOLD_RED)} #{e.message}"
72
- @err.puts @err_paint.call("Run `judgelint --help` for usage.", Paint::DIM)
73
- 2
74
- rescue Error => e
75
- @err.puts "#{@err_paint.call('judgelint:', Paint::BOLD_RED)} #{e.message}"
76
- # Requests that succeeded before the failure are still billed.
77
- cost_line if @usage && @usage.requests.positive?
78
- 2
79
- end
80
-
81
- private
82
-
83
- # Spinel can't compile OptionParser, so the few options are parsed here.
84
- VALUE_OPTIONS = {
85
- "-c" => "config", "--config" => "config", "-f" => "format", "--format" => "format", "--base" => "base",
86
- "-m" => "models", "--model" => "models"
87
- }.freeze
88
-
89
- def parse_options(argv)
90
- rest = []
91
- until argv.empty?
92
- arg = argv.shift
93
- name, inline = arg.start_with?("--") ? arg.split("=", 2) : [arg, nil]
94
- if arg == "--"
95
- rest.concat(argv)
96
- argv = []
97
- elsif VALUE_OPTIONS.key?(name)
98
- value = inline || argv.shift
99
- raise UsageError, "#{name} needs a value" if value.nil?
100
-
101
- set_option(VALUE_OPTIONS.fetch(name), value)
102
- elsif arg == "--no-cache"
103
- @no_cache = true
104
- elsif arg == "--pr"
105
- @pr = true
106
- elsif %w[-y --yes].include?(arg)
107
- @yes = true
108
- elsif %w[-v --version -h --help].include?(arg)
109
- @out.puts(%w[-v --version].include?(arg) ? "judgelint #{VERSION}" : HELP)
110
- @done = true
111
- elsif arg.start_with?("-") && arg != "-"
112
- raise UsageError, "unknown option #{arg}"
113
- else
114
- rest << arg
115
- end
116
- end
117
- rest
118
- end
119
-
120
- def set_option(key, value)
121
- case key
122
- when "config" then @config_path = value
123
- when "base" then @base = value
124
- when "format"
125
- raise UsageError, "--format is #{Reporter::FORMATS.join(', ')}, not #{value}" unless Reporter::FORMATS.include?(value)
126
-
127
- @format = value
128
- else @overrides[key] = value
129
- end
130
- end
131
-
132
- def check
133
- config, rules = load_rules
134
- raise UsageError, "--base and --pr don't go together" if @base && @pr
135
-
136
- base = @pr ? Changes.pr_base : @base
137
- changes = base ? Changes.since(base) : nil
138
- paths = check_paths(rules, changes).reject { |path| Glob.match_any?(config.ignore, path) }
139
- directories = check_directories(rules).reject { |dir| Glob.match_any?(config.ignore, dir) }
140
- units = paths.size + directories.size
141
- runner = runner(config, rules)
142
- jobs = runner.plan(paths, directories: directories, changes: changes)
143
- runner.check_keys(jobs)
144
- guard_cost(config, runner, jobs)
145
- verdicts = runner.execute(jobs).flatten
146
- Reporter.new(@out, format: @format, paint: @paint).check(verdicts, config: config, file_count: units, usage: @usage)
147
- cost_line
148
- verdicts.any?(&:failing?) ? 1 : 0
149
- end
150
-
151
- def check_paths(rules, changes)
152
- if !@argv.empty?
153
- paths = Glob.expand_arguments(@argv)
154
- missing = paths.reject { |path| File.file?(path) }
155
- raise ConfigError, "No such file: #{missing.join(', ')}" unless missing.empty?
156
-
157
- paths = paths.select { |path| changes.key?(path) } if changes
158
- elsif changes
159
- paths = changes.keys.sort.select { |path| File.file?(path) }
160
- else
161
- paths = Glob.files(rules.flat_map(&:paths))
162
- end
163
- paths.select { |path| rules.any? { |rule| !rule.directory? && rule.applies_to?(path) } }.reject { |path| Glob.binary?(path) }
164
- end
165
-
166
- # The directories directory rules govern; with paths named, those the
167
- # paths are in or are. With a change, the runner keeps those it touched.
168
- def check_directories(rules)
169
- directories = rules.select(&:directory?).flat_map(&:directories).uniq.sort
170
- return directories if @argv.empty?
171
-
172
- named = @argv.map { |arg| arg.delete_prefix("./").delete_suffix("/") }
173
- directories.select { |dir| named.any? { |path| path == dir || path.start_with?("#{dir}/") || dir.start_with?("#{path}/") } }
174
- end
175
-
176
- def test
177
- config, rules = load_rules
178
- unless @argv.empty?
179
- unknown = @argv - rules.map(&:id)
180
- raise ConfigError, "Unknown rules: #{unknown.join(', ')}" unless unknown.empty?
181
-
182
- rules = rules.select { |rule| @argv.include?(rule.id) }
183
- end
184
-
185
- runner = runner(config, rules)
186
- jobs = runner.plan_examples
187
- untested = runner.untested
188
- raise ConfigError, "No rule has examples yet. Add some under #{rules.first.examples_dir}/{pass,fail}/" if jobs.empty?
189
-
190
- @err.puts "#{untested.size} #{untested.size == 1 ? 'rule has' : 'rules have'} no examples: #{untested.map(&:id).join(', ')}" unless untested.empty?
191
- runner.check_keys(jobs)
192
- guard_cost(config, runner, jobs)
193
- examples = runner.execute(jobs).flatten
194
- Reporter.new(@out, format: @format, paint: @paint).fixtures(examples, usage: @usage)
195
- cost_line
196
- examples.all?(&:correct?) ? 0 : 1
197
- end
198
-
199
- # Prices the planned requests and refuses a run over max_cost_usd.
200
- def guard_cost(config, runner, jobs)
201
- estimate = runner.estimated_cost(jobs)
202
- return if estimate.nil? || estimate <= config.max_cost_usd || @yes
203
-
204
- raise ConfigError, format("This run would send %d requests, about %s input tokens ($%.2f), over max_cost_usd " \
205
- "($%.2f). Pass --yes to run it anyway.", runner.request_count(jobs),
206
- Usage.delimit(runner.estimated_tokens(jobs)), estimate, config.max_cost_usd)
207
- end
208
-
209
- # What the run cost, and which models answered.
210
- def cost_line
211
- @err.puts @err_paint.call("#{@usage.line}, #{@models}", Paint::DIM)
212
- end
213
-
214
- def list_rules
215
- _config, rules = load_rules
216
- rules.each do |rule|
217
- count = rule.directory? ? "#{rule.directories.size} dirs" : "#{Glob.files(rule.paths).count { |path| rule.applies_to?(path) }} files"
218
- @out.puts format("%-24s %-8s %10s %s", rule.id, rule.severity, count, rule.question || rule.message)
219
- end
220
- 0
221
- end
222
-
223
- def list_providers
224
- PROVIDERS.each do |name, preset|
225
- model = preset["model"] || "(you choose)"
226
- key = preset["api_key_env"] || "no key"
227
- @out.puts format("%-13s %-28s %-22s %s", name, model, key, preset["api_base"] || "(your endpoint)")
228
- @out.puts " needs #{preset['needs']}" if preset["needs"]
229
- end
230
- 0
231
- end
232
-
233
- def init
234
- Scaffold.write(".", @out)
235
- @err.puts "Next: set TYPESAFE_API_KEY, then run `judgelint test` to see the examples judged."
236
- 0
237
- end
238
-
239
- def load_rules
240
- config = Config.load(path: @config_path, overrides: @overrides)
241
- [config, Spec.discover(rules_dir: Config::RULES_DIR, default_threshold: config.threshold, ignore: config.ignore)]
242
- end
243
-
244
- def runner(config, rules)
245
- @usage = Usage.new
246
- @models = config.label
247
- clients = config.models.map { |endpoint| Client.new(endpoint, usage: @usage) }
248
- Runner.new(config: config, rules: rules, clients: clients, cache: Cache.new(@no_cache ? nil : Config::CACHE))
249
- end
250
- end
251
- end