yuno-proofreader 0.1.0 → 0.1.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.
Files changed (45) hide show
  1. checksums.yaml +4 -4
  2. data/CHANGELOG.md +9 -0
  3. data/README.md +169 -58
  4. data/lib/yuno/proofreader/audit/attempt.rb +11 -4
  5. data/lib/yuno/proofreader/audit/report.rb +6 -1
  6. data/lib/yuno/proofreader/audit/runner.rb +27 -13
  7. data/lib/yuno/proofreader/cli/audit_commands.rb +9 -5
  8. data/lib/yuno/proofreader/cli/command_log.rb +4 -0
  9. data/lib/yuno/proofreader/cli/generate_commands.rb +133 -0
  10. data/lib/yuno/proofreader/cli/init_command.rb +24 -10
  11. data/lib/yuno/proofreader/cli/model_commands.rb +10 -2
  12. data/lib/yuno/proofreader/cli/queue_commands.rb +11 -1
  13. data/lib/yuno/proofreader/cli/sheet_commands.rb +4 -1
  14. data/lib/yuno/proofreader/cli.rb +28 -11
  15. data/lib/yuno/proofreader/config.rb +3 -3
  16. data/lib/yuno/proofreader/generate/cache.rb +77 -0
  17. data/lib/yuno/proofreader/generate/collector.rb +115 -0
  18. data/lib/yuno/proofreader/generate/describe.rb +29 -0
  19. data/lib/yuno/proofreader/generate/llm/prompt.rb +62 -0
  20. data/lib/yuno/proofreader/generate/llm/reader.rb +114 -0
  21. data/lib/yuno/proofreader/generate/llm/rules.yml +14 -0
  22. data/lib/yuno/proofreader/generate/llm/wording.rb +20 -0
  23. data/lib/yuno/proofreader/generate/llms_builder.rb +50 -0
  24. data/lib/yuno/proofreader/generate/llms_report.rb +112 -0
  25. data/lib/yuno/proofreader/generate/llms_txt.rb +107 -0
  26. data/lib/yuno/proofreader/generate/llms_writer.rb +54 -0
  27. data/lib/yuno/proofreader/generate/outline.rb +91 -0
  28. data/lib/yuno/proofreader/generate/passage.rb +54 -0
  29. data/lib/yuno/proofreader/generate/saved_answer.rb +50 -0
  30. data/lib/yuno/proofreader/llm/defaults.yml +3 -0
  31. data/lib/yuno/proofreader/llm/factory.rb +9 -6
  32. data/lib/yuno/proofreader/llm/handoff.rb +114 -0
  33. data/lib/yuno/proofreader/llm/provider.rb +4 -1
  34. data/lib/yuno/proofreader/llm/providers/manual.rb +44 -0
  35. data/lib/yuno/proofreader/llm/providers.rb +4 -10
  36. data/lib/yuno/proofreader/site.rb +2 -1
  37. data/lib/yuno/proofreader/site_reader.rb +29 -3
  38. data/lib/yuno/proofreader/store/gateways/csv.rb +79 -0
  39. data/lib/yuno/proofreader/store/sheets.rb +8 -4
  40. data/lib/yuno/proofreader/version.rb +1 -1
  41. data/lib/yuno/proofreader.rb +17 -0
  42. data/proofreader.example.yml +31 -7
  43. metadata +41 -7
  44. data/lib/yuno/proofreader/llm/model_commands.rb +0 -34
  45. /data/lib/yuno/proofreader/store/{google_gateway.rb → gateways/google.rb} +0 -0
@@ -0,0 +1,54 @@
1
+ # frozen_string_literal: true
2
+
3
+ require "nokogiri"
4
+
5
+ module Yuno
6
+ module Proofreader
7
+ module Generate
8
+ # The text of a page as the model gets it: its paragraphs, whole and in order, outside the header, the
9
+ # navigation and the footer. Nothing is cut inside a paragraph. With a budget, paragraphs are taken from the
10
+ # start while they fit, and the first one is always taken, however long it is. cut says whether some were left.
11
+ module Passage
12
+ Body = Data.define(:paragraphs, :cut)
13
+
14
+ MIN_PARAGRAPH = 40
15
+ # Characters of text handed over for a page of each tier. It keeps the request small and says nothing about
16
+ # how much the model may write. A page of a lower tier, or one the analysis has not ranked, gets the smallest.
17
+ BUDGETS = { 1 => 4_000, 2 => 2_500, 3 => 1_500 }.freeze
18
+ DEFAULT_BUDGET = 800
19
+ MAIN = "main, [role=main]"
20
+ OUTSIDE_CHROME = "not(ancestor::header or ancestor::nav or ancestor::footer or ancestor::aside or " \
21
+ "ancestor::*[@role='banner' or @role='navigation' or @role='contentinfo'])"
22
+
23
+ module_function
24
+
25
+ def budget(tier) = BUDGETS.fetch(tier, DEFAULT_BUDGET)
26
+
27
+ # budget: characters to hand over, or nil for all of the text.
28
+ def call(html, budget: nil)
29
+ paragraphs = paragraphs_of(html)
30
+ return Body.new(paragraphs:, cut: false) unless budget
31
+
32
+ taken = []
33
+ used = 0
34
+ paragraphs.each do |paragraph|
35
+ break if !taken.empty? && used + paragraph.length > budget
36
+
37
+ taken << paragraph
38
+ used += paragraph.length
39
+ end
40
+ Body.new(paragraphs: taken, cut: taken.size < paragraphs.size)
41
+ end
42
+
43
+ def paragraphs_of(html)
44
+ doc = Nokogiri::HTML(html.to_s)
45
+ scope = doc.at_css(MAIN) || doc.at_css("body")
46
+ return [] unless scope
47
+
48
+ texts = scope.xpath(".//p[#{OUTSIDE_CHROME}]").map { |node| Findings::Text.collapse(node.text) }
49
+ texts.select { |text| text.length >= MIN_PARAGRAPH }.uniq
50
+ end
51
+ end
52
+ end
53
+ end
54
+ end
@@ -0,0 +1,50 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Yuno
4
+ module Proofreader
5
+ module Generate
6
+ # Stands in for the model client when the answer may already be on disk, as with the manual provider after an
7
+ # earlier run. If the prompt file holds exactly the prompt it is asked for, it uses the answer file (or waits for
8
+ # it) instead of asking again. Otherwise it asks as usual: a new prompt is written, and an answer that was in the
9
+ # answer file is kept as answer.previous.md.
10
+ class SavedAnswer
11
+ LANGUAGE_IN_PROMPT = /## Material\s*\{"language":"([^"]+)"/
12
+
13
+ def initialize(handoff:, model:, say: ->(_message) {})
14
+ @handoff = handoff
15
+ @model = model
16
+ @say = say
17
+ end
18
+
19
+ # The languages, with the one whose prompt is in the prompt file first, so that its answer is used before
20
+ # another question replaces it.
21
+ def order(languages)
22
+ text = @handoff.prompt_text
23
+ saved = text && text[LANGUAGE_IN_PROMPT, 1]
24
+ languages.include?(saved) ? [saved, *(languages - [saved])] : languages
25
+ end
26
+
27
+ def generate(system:, user:, **)
28
+ Llm::Answer.new(data: Llm::JsonText.parse(text_for(system, user)), model: @model, finish: "STOP",
29
+ input_tokens: 0, output_tokens: 0, thinking_tokens: 0, seconds: 0.0)
30
+ end
31
+
32
+ private
33
+
34
+ def text_for(system, user)
35
+ return @handoff.await(check: method(:problem_with)) if @handoff.prompt_written?(system:, user:)
36
+
37
+ @say.call("#{@handoff.prompt_path} is not the prompt for this language, so a new prompt is written.")
38
+ @handoff.ask(system:, user:, label: @model, check: method(:problem_with))
39
+ end
40
+
41
+ def problem_with(text)
42
+ Llm::JsonText.parse(text)
43
+ nil
44
+ rescue Llm::AnswerError => e
45
+ "#{e.message} Fix the file and press Enter, or press Ctrl-C to stop."
46
+ end
47
+ end
48
+ end
49
+ end
50
+ end
@@ -4,3 +4,6 @@ gemini:
4
4
  - gemini-3.8-flash
5
5
  - gemini-3.7-flash
6
6
  - gemini-3.6-flash
7
+
8
+ manual:
9
+ - your chat model
@@ -8,16 +8,19 @@ module Yuno
8
8
  Selection = Data.define(:names, :source)
9
9
 
10
10
  class << self
11
- # The provider of the site, with its API key from the environment.
12
11
  def provider_for(site, env: ENV, transport: nil)
13
12
  klass = Providers.resolve(site.provider)
13
+ key = api_key_from(klass, env)
14
+ klass.new(api_key: key, **(transport ? { transport: } : {}))
15
+ end
16
+
17
+ def api_key_from(klass, env)
18
+ return nil unless klass.api_key_env
19
+
14
20
  key = env[klass.api_key_env].to_s.strip
15
- if key.empty?
16
- raise ConfigError,
17
- "Missing environment variable #{klass.api_key_env}: your #{klass.id} API key."
18
- end
21
+ return key unless key.empty?
19
22
 
20
- klass.new(api_key: key, **(transport ? { transport: } : {}))
23
+ raise ConfigError, "Missing environment variable #{klass.api_key_env}: your #{klass.id} API key."
21
24
  end
22
25
 
23
26
  # The settings win. For the second review, review_models win over models. Without any, the provider's
@@ -0,0 +1,114 @@
1
+ # frozen_string_literal: true
2
+
3
+ require "fileutils"
4
+
5
+ module Yuno
6
+ module Proofreader
7
+ module Llm
8
+ # A manual round trip with a model that runs somewhere else, such as a chat in the browser
9
+ class Handoff
10
+ DEFAULT_DIR = "tmp/handoff"
11
+ PREAMBLE = "Reply with only what the instructions ask for: no introduction and no closing remarks. " \
12
+ "Put the whole reply in one code block, so it can be copied exactly."
13
+
14
+ # Where the files go unless told otherwise. PROOFREADER_HANDOFF_DIR moves them, which the tests use.
15
+ def self.default_dir = ENV.fetch("PROOFREADER_HANDOFF_DIR", DEFAULT_DIR)
16
+
17
+ def self.interactive? = true
18
+
19
+ attr_reader :prompt_path, :answer_path, :previous_path
20
+
21
+ def initialize(dir: self.class.default_dir, input: $stdin, output: $stdout)
22
+ @prompt_path = File.join(dir, "prompt.md")
23
+ @answer_path = File.join(dir, "answer.md")
24
+ @previous_path = File.join(dir, "answer.previous.md")
25
+ @input = input
26
+ @output = output
27
+ end
28
+
29
+ # label: what to tell the person to pick in the chat, for example the model name.
30
+ def ask(system:, user:, label: nil, check: nil)
31
+ FileUtils.mkdir_p(File.dirname(@prompt_path))
32
+ keep_previous_answer
33
+ File.write(@answer_path, "")
34
+ File.write(@prompt_path, document(system, user))
35
+ @output.puts "Prompt written to #{@prompt_path}#{" (use #{label})" if label}."
36
+ wait(check)
37
+ File.read(@answer_path)
38
+ end
39
+
40
+ # Whether the prompt file is exactly the one these texts would produce, so an answer saved next to it
41
+ # belongs to them.
42
+ def prompt_written?(system:, user:)
43
+ File.file?(@prompt_path) && File.read(@prompt_path) == document(system, user)
44
+ end
45
+
46
+ # Waits for the answer to a prompt that is already written. It writes no prompt and does not empty the answer
47
+ # file. An answer that is already there and passes the check is used at once.
48
+ def await(check: nil)
49
+ FileUtils.mkdir_p(File.dirname(@answer_path))
50
+ File.write(@answer_path, "") unless File.file?(@answer_path)
51
+ saved = saved_answer(check)
52
+ return saved if saved
53
+
54
+ wait(check)
55
+ File.read(@answer_path)
56
+ end
57
+
58
+ # The text of the prompt file, or nil when there is none.
59
+ def prompt_text = (File.read(@prompt_path) if File.file?(@prompt_path))
60
+
61
+ private
62
+
63
+ def document(system, user)
64
+ [PREAMBLE, "## Instructions\n\n#{system}", "## Material\n\n#{user}"].join("\n\n") << "\n"
65
+ end
66
+
67
+ def wait(check)
68
+ loop do
69
+ @output.puts "Save the reply as #{@answer_path}, then press Enter."
70
+ if @input.gets.nil?
71
+ raise ProviderError.new("No input to wait on. Run it in an interactive terminal.",
72
+ kind: :other)
73
+ end
74
+
75
+ problem = problem_with_answer(check)
76
+ return unless problem
77
+
78
+ @output.puts problem
79
+ end
80
+ end
81
+
82
+ def problem_with_answer(check)
83
+ return "#{@answer_path} is missing or empty." unless answered?
84
+
85
+ check&.call(File.read(@answer_path))
86
+ end
87
+
88
+ def answered?
89
+ File.file?(@answer_path) && !File.read(@answer_path).strip.empty?
90
+ end
91
+
92
+ # The answer that is already in the file, when there is one and it passes the check. A bad one is explained.
93
+ def saved_answer(check)
94
+ return unless answered?
95
+
96
+ text = File.read(@answer_path)
97
+ problem = check&.call(text)
98
+ unless problem
99
+ @output.puts "Using the answer saved in #{@answer_path}."
100
+ return text
101
+ end
102
+
103
+ @output.puts problem
104
+ nil
105
+ end
106
+
107
+ # An answer that was never used is not lost when the next question starts. Only the last one is kept.
108
+ def keep_previous_answer
109
+ FileUtils.cp(@answer_path, @previous_path) if answered?
110
+ end
111
+ end
112
+ end
113
+ end
114
+ end
@@ -21,11 +21,14 @@ module Yuno
21
21
  raise NotImplementedError, "#{name} must define .id"
22
22
  end
23
23
 
24
- # The environment variable that holds its API key.
24
+ # The environment variable that holds its API key, may be nil
25
25
  def self.api_key_env
26
26
  raise NotImplementedError, "#{name} must define .api_key_env"
27
27
  end
28
28
 
29
+ # Whether a person has to answer each question. A batch of several pages cannot work then.
30
+ def self.interactive? = false
31
+
29
32
  def initialize(api_key:, transport: HttpTransport.new, timeout: TIMEOUT)
30
33
  @api_key = api_key
31
34
  @transport = transport
@@ -0,0 +1,44 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Yuno
4
+ module Proofreader
5
+ module Llm
6
+ # The model providers that are installed. Each wrapper registers itself when it is loaded.
7
+ module Providers
8
+ # Prompt goes to a file instead of the API, a person asks a model by hand and saves the answer to another file.
9
+ class Manual < Provider
10
+ def self.id = "manual"
11
+
12
+ def self.api_key_env = nil
13
+
14
+ def self.interactive? = true
15
+
16
+ def initialize(handoff: Handoff.new, api_key: nil, **)
17
+ super(api_key:, **)
18
+ @handoff = handoff
19
+ end
20
+
21
+ # No output limit
22
+ def complete(model:, system:, user:, **)
23
+ text = @handoff.ask(system:, user:, label: model, check: method(:problem_with))
24
+ Completion.new(text:, finish: "STOP", input_tokens: 0, output_tokens: 0, thinking_tokens: 0)
25
+ end
26
+
27
+ def models = []
28
+
29
+ private
30
+
31
+ # The client reads every answer as JSON, so a bad paste is caught here and awaited upon
32
+ def problem_with(text)
33
+ JsonText.parse(text)
34
+ nil
35
+ rescue AnswerError => e
36
+ "#{e.message} Fix the file and press Enter, or press Ctrl-C to stop."
37
+ end
38
+ end
39
+
40
+ register(Manual)
41
+ end
42
+ end
43
+ end
44
+ end
@@ -5,6 +5,8 @@ module Yuno
5
5
  module Llm
6
6
  # The providers that are installed. Each wrapper registers itself when it is loaded.
7
7
  module Providers
8
+ DEFAULT_ID = "manual"
9
+
8
10
  @registry = {}
9
11
 
10
12
  class << self
@@ -14,23 +16,15 @@ module Yuno
14
16
 
15
17
  def ids = @registry.keys
16
18
 
17
- # The provider named in the settings. Without a name, the only installed one.
19
+ # The provider named in the settings. Without a name, the manual one: it needs no account or key.
18
20
  def resolve(id)
19
21
  name = id.to_s.strip.downcase
20
- return only_provider if name.empty?
22
+ name = DEFAULT_ID if name.empty?
21
23
 
22
24
  @registry.fetch(name) do
23
25
  raise ConfigError, "Site: unknown provider #{name.inspect}. Available: #{ids.join(', ')}"
24
26
  end
25
27
  end
26
-
27
- private
28
-
29
- def only_provider
30
- return @registry.values.first if @registry.size == 1
31
-
32
- raise ConfigError, "Site: set provider to one of: #{ids.join(', ')}"
33
- end
34
28
  end
35
29
  end
36
30
  end
@@ -7,7 +7,8 @@ module Yuno
7
7
  module Proofreader
8
8
  # What you tell the tool about your website. Read from a YAML file.
9
9
  Site = Data.define(:website, :prefixes, :language_notes, :sitemap_url, :default_language_only_paths,
10
- :skip_paths, :provider, :models, :review_models, :context, :analysis, :cadence) do
10
+ :skip_paths, :provider, :models, :review_models, :review, :store, :data_dir, :context,
11
+ :analysis, :cadence) do
11
12
  def self.load(path)
12
13
  raise ConfigError, "Site file not found: #{path}" unless File.file?(path)
13
14
 
@@ -5,13 +5,16 @@ module Yuno
5
5
  # Turns the parsed YAML of a settings file into a Site, with a clear error for anything that is wrong.
6
6
  class SiteReader
7
7
  SITE_KEYS = %w[website languages sitemap_url default_language_only_paths skip_paths provider models
8
- review_models analysis cadence].freeze
8
+ review_models review store data_dir analysis cadence].freeze
9
9
  PROVIDER_ID = /\A[a-z][a-z0-9_-]{0,39}\z/
10
10
  MODEL_NAME = %r{\A[A-Za-z0-9][A-Za-z0-9._:/-]{0,99}\z}
11
11
  MAX_MODELS = 8
12
12
  KEYS = (SITE_KEYS + Context::KEYS).freeze
13
13
  LANGUAGE_KEYS = %w[code prefix notes].freeze
14
14
  LANGUAGE_CODE = /\A[a-z]{2,3}(-[a-z0-9]+)*\z/
15
+ STORES = %w[csv sheets].freeze
16
+ DEFAULT_STORE = "csv"
17
+ DEFAULT_DATA_DIR = "data"
15
18
 
16
19
  def self.call(hash) = new(hash).call
17
20
 
@@ -28,8 +31,10 @@ module Yuno
28
31
  website: @raw["website"].to_s.strip.chomp("/"), prefixes:, language_notes: notes,
29
32
  sitemap_url: sitemap_url, default_language_only_paths: paths("default_language_only_paths"),
30
33
  skip_paths: paths("skip_paths"), provider: provider_name, models: model_list("models"),
31
- review_models: model_list("review_models"), context: Context.from_hash(@raw),
32
- analysis: Analysis::Settings.from_hash(@raw["analysis"]), cadence: Audit::Cadence.from_hash(@raw["cadence"])
34
+ review_models: model_list("review_models"), store: store_name, data_dir: data_dir,
35
+ review: review_flag,
36
+ context: Context.from_hash(@raw), analysis: Analysis::Settings.from_hash(@raw["analysis"]),
37
+ cadence: Audit::Cadence.from_hash(@raw["cadence"])
33
38
  ).validate!
34
39
  end
35
40
 
@@ -115,6 +120,27 @@ module Yuno
115
120
  raise ConfigError, "Site: provider must be a short lowercase name (got #{@raw['provider'].inspect})"
116
121
  end
117
122
 
123
+ def store_name
124
+ name = Context.text(@raw["store"], "store", 20).downcase
125
+ return DEFAULT_STORE if name.empty?
126
+ return name if STORES.include?(name)
127
+
128
+ raise ConfigError, "Site: store must be #{STORES.join(' or ')} (got #{@raw['store'].inspect})"
129
+ end
130
+
131
+ def review_flag
132
+ value = @raw["review"]
133
+ return false if value.nil?
134
+ return value if [true, false].include?(value)
135
+
136
+ raise ConfigError, "Site: review must be true or false (got #{value.inspect})"
137
+ end
138
+
139
+ def data_dir
140
+ dir = Context.text(@raw["data_dir"], "data_dir", 200)
141
+ dir.empty? ? DEFAULT_DATA_DIR : dir
142
+ end
143
+
118
144
  def model_list(key)
119
145
  items = Array(@raw[key])
120
146
  raise ConfigError, "Site: #{key} must be a list of model names, written as text" unless items.all?(String)
@@ -0,0 +1,79 @@
1
+ # frozen_string_literal: true
2
+
3
+ require "csv"
4
+ require "fileutils"
5
+
6
+ module Yuno
7
+ module Proofreader
8
+ module Store
9
+ # Keeps the tabs in a folder of CSV files, one file per tab, named after it in lowercase (pages.csv). It
10
+ # offers what a Google Sheet gateway offers, so Store::Sheets works on it unchanged.
11
+ class CsvGateway
12
+ EPOCH = Time.utc(1899, 12, 30)
13
+
14
+ def initialize(dir:, schemas:)
15
+ @dir = dir
16
+ @types = schemas.to_h { |schema| [schema.title, schema.columns.to_h { |column| [column.name, column.type] }] }
17
+ end
18
+
19
+ def tabs = @types.keys.select { |title| File.file?(path(title)) }.to_h { |title| [title, title] }
20
+
21
+ def add_tab(title, **)
22
+ raise StoreError, "The tab #{title} exists" if File.exist?(path(title))
23
+
24
+ FileUtils.mkdir_p(@dir)
25
+ File.write(path(title), "", encoding: "UTF-8")
26
+ title
27
+ end
28
+
29
+ def delete_tab(sheet_id) = FileUtils.rm_f(path(sheet_id))
30
+
31
+ def read(title)
32
+ raise StoreError, "Tab #{title} not found. Run: yuno-proofreader prepare" unless File.file?(path(title))
33
+
34
+ CSV.read(path(title), encoding: "UTF-8").map { |row| row.map(&:to_s) }
35
+ rescue CSV::MalformedCSVError => e
36
+ raise StoreError, "#{path(title)} is not valid CSV (#{e.message})"
37
+ end
38
+
39
+ def append(title, rows) = write(title, read(title) + rows)
40
+
41
+ def update_cells(title, cells)
42
+ return if cells.empty?
43
+
44
+ rows = read(title)
45
+ cells.each do |row, column, value|
46
+ rows << [] while rows.size < row
47
+ line = rows[row - 1]
48
+ line << "" while line.size < column
49
+ line[column - 1] = value
50
+ end
51
+ write(title, rows)
52
+ end
53
+
54
+ # There is nothing to format in a CSV file.
55
+ def format_tab(_sheet_id, _schema) = nil
56
+
57
+ private
58
+
59
+ # Written to a temporary file first, so a crash cannot leave half a file behind.
60
+ def write(title, rows)
61
+ header = rows.first.to_a.map { |name| name.to_s.strip.downcase }
62
+ types = @types.fetch(title, {})
63
+ text = CSV.generate do |csv|
64
+ rows.each { |row| csv << row.each_with_index.map { |value, index| render(value, types[header[index]]) } }
65
+ end
66
+ temporary = "#{path(title)}.tmp"
67
+ File.write(temporary, text, encoding: "UTF-8")
68
+ File.rename(temporary, path(title))
69
+ end
70
+
71
+ def render(value, type) = type == :datetime && value.is_a?(Numeric) ? stamp(value) : value.to_s
72
+
73
+ def stamp(serial) = (EPOCH + (serial * 86_400).round).strftime("%Y-%m-%d %H:%M")
74
+
75
+ def path(title) = File.join(@dir, "#{title.downcase}.csv")
76
+ end
77
+ end
78
+ end
79
+ end
@@ -3,18 +3,22 @@
3
3
  module Yuno
4
4
  module Proofreader
5
5
  module Store
6
- # Keeps the pages, the suggestions and the analysis in a Google Sheet. Columns are found by their header
7
- # names, so the order of the columns does not matter and extra columns are left alone. All access goes through
8
- # a gateway.
6
+ # Keeps the pages, the suggestions and the analysis in tabs, as the rows of a Google Sheet or as CSV files.
9
7
  class Sheets
10
8
  Table = Data.define(:index, :rows, :width)
11
9
  IMPORTANCE = %w[importance tier importance_notes analyzed_at].freeze
12
10
 
13
11
  def self.connect(config, site)
14
- require_relative "google_gateway"
12
+ require_relative "gateways/google"
15
13
  new(GoogleGateway.new(spreadsheet_id: config.spreadsheet_id), site)
16
14
  end
17
15
 
16
+ # The same store on a folder of CSV files.
17
+ def self.local(site, dir:)
18
+ schemas = [Schema.pages(site.languages), Schema.suggestions, Schema.analysis]
19
+ new(CsvGateway.new(dir:, schemas:), site)
20
+ end
21
+
18
22
  def initialize(gateway, site)
19
23
  @gateway = gateway
20
24
  @languages = site.languages
@@ -2,6 +2,6 @@
2
2
 
3
3
  module Yuno
4
4
  module Proofreader
5
- VERSION = "0.1.0"
5
+ VERSION = "0.1.1"
6
6
  end
7
7
  end
@@ -25,6 +25,7 @@ require_relative "proofreader/store/cells"
25
25
  require_relative "proofreader/store/memory"
26
26
  require_relative "proofreader/store/sheets"
27
27
  require_relative "proofreader/store/tab_setup"
28
+ require_relative "proofreader/store/gateways/csv"
28
29
  require_relative "proofreader/context"
29
30
  require_relative "proofreader/site_reader"
30
31
  require_relative "proofreader/findings/text"
@@ -61,6 +62,8 @@ require_relative "proofreader/llm/http_transport"
61
62
  require_relative "proofreader/llm/provider"
62
63
  require_relative "proofreader/llm/providers"
63
64
  require_relative "proofreader/llm/providers/gemini"
65
+ require_relative "proofreader/llm/providers/manual"
66
+ require_relative "proofreader/llm/handoff"
64
67
  require_relative "proofreader/llm/defaults"
65
68
  require_relative "proofreader/llm/client"
66
69
  require_relative "proofreader/llm/factory"
@@ -78,6 +81,20 @@ require_relative "proofreader/audit/agenda"
78
81
  require_relative "proofreader/audit/batch"
79
82
  require_relative "proofreader/audit/agenda_report"
80
83
  require_relative "proofreader/audit/batch_report"
84
+ require_relative "proofreader/generate/passage"
85
+ require_relative "proofreader/generate/collector"
86
+ require_relative "proofreader/generate/cache"
87
+ require_relative "proofreader/generate/saved_answer"
88
+ require_relative "proofreader/generate/outline"
89
+ require_relative "proofreader/generate/describe"
90
+ require_relative "proofreader/generate/llm/wording"
91
+ require_relative "proofreader/generate/llm/prompt"
92
+ require_relative "proofreader/generate/llm/reader"
93
+ require_relative "proofreader/generate/llms_txt"
94
+ require_relative "proofreader/generate/llms_builder"
95
+ require_relative "proofreader/generate/llms_writer"
96
+ require_relative "proofreader/generate/llms_report"
97
+ require_relative "proofreader/cli/generate_commands"
81
98
  require_relative "proofreader/cli/audit_commands"
82
99
  require_relative "proofreader/cli/command_log"
83
100
  require_relative "proofreader/cli/model_commands"
@@ -76,23 +76,47 @@ intentional_differences:
76
76
  - "[FILL IN] One difference between language versions that is intended, such as a section that exists in one language only."
77
77
 
78
78
  # ---- The AI models ----------------------------------------------------------------------------
79
- # Everything here is optional.
79
+ # Everything here is optional. Out of the box nothing needs an account or a key: the tool writes each
80
+ # prompt to tmp/handoff/prompt.md, you paste it into a chat with the model of your choice, save the reply
81
+ # as tmp/handoff/answer.md and press Enter.
80
82
  #
81
- # provider Which family of models to use. Leave it out while only one is installed.
82
- # models The models to use, best first. When one is overloaded, over its limit or not available to
83
- # your key, the next one is used. The tool has a built-in list to fall back on, but model
84
- # names change often, so set your own. `yuno-proofreader models` shows which ones your key
85
- # can use. The names below are only examples.
83
+ # provider Which family of models to use: manual (the default) or gemini.
84
+ # models For gemini: the models to use, best first. When one is overloaded, over its limit or not
85
+ # available to your key, the next one is used. The tool has a built-in list to fall back
86
+ # on, but model names change often, so set your own. `yuno-proofreader models` shows which
87
+ # ones your key can use. The names below are only examples.
88
+ # For manual: only a label, shown to remind you which model to pick in the chat.
86
89
  # review_models Optional list for the independent second review, which prefers a different model from the
87
90
  # first audit. Leave it out to use `models`. With only one model there is nothing for the
88
91
  # review to be independent of.
92
+ # review true or false (the default). With true, every audit is followed by an independent second
93
+ # review by a different model, which sends the page to a model a second time and so costs
94
+ # about as much again. `audit --review` turns it on for one run.
89
95
  #
90
96
  # provider: gemini
91
97
  # models:
92
98
  # - gemini-3.8-flash
93
99
  # - gemini-3.7-flash
94
100
  # review_models:
95
- # - gemini-3.6-flash
101
+ # - gemini-3.8-flash-lite
102
+ # - gemini-3.7-flash-lite
103
+ #
104
+ # Not connecting to any API, but instead using tmp/handoff and copying manually to any model (in the AI's UI website, for example)
105
+ # provider: manual
106
+ # - fabel-5.2
107
+
108
+ # ---- Where the results are kept (optional) -------------------------------------------------------
109
+ # Everything here is optional. Out of the box nothing needs an account: the pages, the suggestions and the
110
+ # analysis are kept in CSV files that you can open in any spreadsheet program.
111
+ #
112
+ # store csv (the default) or sheets. With sheets the same tabs are kept in a Google Sheet, which needs
113
+ # SPREADSHEET_ID and Google credentials outside this file (see the README, "Connecting to Google").
114
+ # data_dir The folder for the CSV files (pages.csv, suggestions.csv, analysis.csv), relative to where you
115
+ # run the tool. Default: data. Keep it: it holds the fingerprints and your decisions, and deleting
116
+ # it brings back every suggestion you rejected. Ignored with sheets.
117
+ #
118
+ # store: sheets
119
+ # data_dir: data
96
120
 
97
121
  # ---- The analysis of the site (optional) -------------------------------------------------------
98
122
  # Used by `yuno-proofreader analyze`, which ranks the pages of the site by importance. Everything here is