prosefix 0.2.0__tar.gz → 0.3.0__tar.gz
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.
- {prosefix-0.2.0 → prosefix-0.3.0}/PKG-INFO +47 -8
- {prosefix-0.2.0 → prosefix-0.3.0}/README.md +43 -4
- {prosefix-0.2.0 → prosefix-0.3.0}/man/prosefix.1 +357 -18
- {prosefix-0.2.0 → prosefix-0.3.0}/prosefix/__init__.py +1 -1
- {prosefix-0.2.0 → prosefix-0.3.0}/prosefix/cli.py +149 -20
- prosefix-0.3.0/prosefix/config.py +169 -0
- {prosefix-0.2.0 → prosefix-0.3.0}/prosefix/engine.py +225 -24
- {prosefix-0.2.0 → prosefix-0.3.0}/prosefix/jsonout.py +35 -5
- {prosefix-0.2.0 → prosefix-0.3.0}/prosefix/settings.py +19 -16
- prosefix-0.3.0/prosefix/tools.py +58 -0
- {prosefix-0.2.0 → prosefix-0.3.0}/pyproject.toml +2 -2
- {prosefix-0.2.0 → prosefix-0.3.0}/tests/test_cli.py +227 -2
- prosefix-0.3.0/tests/test_config.py +331 -0
- prosefix-0.3.0/tests/test_decide.py +239 -0
- {prosefix-0.2.0 → prosefix-0.3.0}/tests/test_engine.py +79 -0
- prosefix-0.2.0/prosefix/tools.py +0 -26
- {prosefix-0.2.0 → prosefix-0.3.0}/.gitignore +0 -0
- {prosefix-0.2.0 → prosefix-0.3.0}/LICENSE +0 -0
- {prosefix-0.2.0 → prosefix-0.3.0}/tests/conftest.py +0 -0
- {prosefix-0.2.0 → prosefix-0.3.0}/tests/data/walkthrough.md +0 -0
- {prosefix-0.2.0 → prosefix-0.3.0}/tests/test_docs.py +0 -0
- {prosefix-0.2.0 → prosefix-0.3.0}/tests/test_settings.py +0 -0
- {prosefix-0.2.0 → prosefix-0.3.0}/tests/test_walkthrough.py +0 -0
- {prosefix-0.2.0 → prosefix-0.3.0}/tests/vault/obsidian.md +0 -0
- {prosefix-0.2.0 → prosefix-0.3.0}/tests/vault/off.md +0 -0
- {prosefix-0.2.0 → prosefix-0.3.0}/tests/vault/plain.md +0 -0
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.5
|
|
2
2
|
Name: prosefix
|
|
3
|
-
Version: 0.
|
|
3
|
+
Version: 0.3.0
|
|
4
4
|
Summary: Fix spelling, style, typos and punctuation in Markdown files, in place.
|
|
5
5
|
Project-URL: Homepage, https://github.com/AndrewBroz/prosefix
|
|
6
6
|
Project-URL: Issues, https://github.com/AndrewBroz/prosefix/issues
|
|
@@ -14,10 +14,10 @@ Classifier: Programming Language :: Python :: 3
|
|
|
14
14
|
Classifier: Programming Language :: Python :: 3.11
|
|
15
15
|
Classifier: Topic :: Text Processing :: Markup :: Markdown
|
|
16
16
|
Requires-Python: >=3.11
|
|
17
|
-
Requires-Dist: adjudicate<0.4,>=0.3.
|
|
18
|
-
Requires-Dist: proofix<0.
|
|
17
|
+
Requires-Dist: adjudicate<0.4,>=0.3.6
|
|
18
|
+
Requires-Dist: proofix<0.9,>=0.8.2
|
|
19
19
|
Requires-Dist: pyyaml>=6
|
|
20
|
-
Requires-Dist: stylefix<0.
|
|
20
|
+
Requires-Dist: stylefix<0.11,>=0.10.1
|
|
21
21
|
Description-Content-Type: text/markdown
|
|
22
22
|
|
|
23
23
|
# prosefix
|
|
@@ -39,7 +39,7 @@ Before: We recieved the the new colour scheme -- the teams programme , which co
|
|
|
39
39
|
After: We received the new colour scheme – the teams programme, which covers analysis, design and testing.
|
|
40
40
|
```
|
|
41
41
|
|
|
42
|
-
(A British draft, kept British, with the tools installed and no model. Words that depend on meaning, such as licence and license, are listed for review until a model decides them.)
|
|
42
|
+
(A British draft, kept British, with the tools installed and no model. Words that depend on meaning, such as licence and license, are listed for review until a model decides them; see [Questions without a model](#first-run).)
|
|
43
43
|
|
|
44
44
|
## Install
|
|
45
45
|
|
|
@@ -55,7 +55,7 @@ Without Homebrew, install the tools you want. prosefix runs every tier whose req
|
|
|
55
55
|
| [Vale](https://vale.sh) (`brew install vale`) | `variety`, `guide`, `ambiguous`, `numbers` | `serial-comma`, `abbreviations`, `punctuation`, and all of the proof pass |
|
|
56
56
|
| [LanguageTool](https://languagetool.org) (`brew install languagetool`) | `mechanical`, `adjudicated` | `hygiene`, `basics`, `compounds`, `commas` |
|
|
57
57
|
| [typos](https://github.com/crate-ci/typos) (`brew install typos-cli`) | `typos` | everything else |
|
|
58
|
-
| a model | decisions that need judgement, `commas` | rule-based tiers; undecided items are listed for review |
|
|
58
|
+
| a model | decisions that need judgement, `commas` | rule-based tiers; undecided items are listed for review (see [Questions without a model](#first-run)) |
|
|
59
59
|
|
|
60
60
|
## First run
|
|
61
61
|
|
|
@@ -79,7 +79,9 @@ prosefix --setup # choose and test a model endpoint
|
|
|
79
79
|
prosefix --doctor # tools found or missing, the endpoint, the settings file for this directory
|
|
80
80
|
```
|
|
81
81
|
|
|
82
|
-
The endpoint comes from flags, `PROSEFIX_LLM_*` / `ADJUDICATE_LLM_*` environment variables, `~/.config/prosefix/config.toml` and `~/.config/adjudicate/config.toml`, never from a project file. Without a model,
|
|
82
|
+
The endpoint comes from flags, `PROSEFIX_LLM_*` / `ADJUDICATE_LLM_*` environment variables, `~/.config/prosefix/config.toml` and `~/.config/adjudicate/config.toml`, never from a project file. Without a model, all rule-based tiers still run.
|
|
83
|
+
|
|
84
|
+
**Questions without a model.** Some items need judgement but have a likely answer: a capitalised swap (`Color` to `Colour`), a serial comma, a number the guide may spell out, an abbreviation that may end a sentence, and a comma or full stop at a closing quote. Without a model, prosefix asks about each one whenever it can store your answer, that is, whenever it uses a decision cache. The question is listed for review, and the text is left as written. `--llm none` and `--no-cache` store nothing, so they do not ask: they apply the capitalised swap and list the others as plain review items. Before 0.3.0, only `--llm cached` asked.
|
|
83
85
|
|
|
84
86
|
### Which English
|
|
85
87
|
|
|
@@ -173,7 +175,44 @@ The tiers are `variety`, `guide`, `ambiguous`, `numbers`, `serial-comma`, `abbre
|
|
|
173
175
|
|
|
174
176
|
## JSON
|
|
175
177
|
|
|
176
|
-
`prosefix --json` prints one document, `"schema": 1`, for editors and plugins
|
|
178
|
+
`prosefix --json` prints one document, `"schema": 1`, for editors and plugins. It holds the endpoint, the capabilities skipped and an entry for each file. Each entry has the file's status, settings, `input_sha256`, a list of changes (`id`, `pass`, `check`, `start`, `end`, `line`, `before`, `after`, `reason`, `decided_by`, `confidence`, `depends_on`), review items and the full output. The settings include `target_source`, one of `flag`, `front matter`, `lang`, `project`, `detected` or `default`. They include `detected` word counts when detection ran, and `"variety_conversion": false` when no clear variety meant the variety spellings were left alone. `input_sha256` is the SHA-256 of the input as UTF-8, so a plugin can tell whether the note changed after the run. Change offsets are UTF-16 code units into the whole input file; `line` is 1-based. A change that lists `depends_on` supersedes the changes it names. `decided_by` is `rule`, `model`, `cache` or `user`; `user` marks a change made from your answer. A file with `"status": "error"` has only `path`, `status`, `reason` and `settings`.
|
|
179
|
+
|
|
180
|
+
**Settled output.** prosefix runs again on its own output until a run changes nothing. So `output` is settled: a run on it reports `unchanged`, with the same questions and keys. The review items come from that last run. This happens in every mode, so an in-place write gives the same text as `output`.
|
|
181
|
+
|
|
182
|
+
**Questions.** A review item with `options` is a question. Only a question has these fields:
|
|
183
|
+
|
|
184
|
+
- `start` and `end`: UTF-16 offsets into `output`, not into the input, left out when they cannot be placed there;
|
|
185
|
+
- `options`: the replacements on offer (keeping the text as written is always possible, and never listed);
|
|
186
|
+
- `suggestion`: the model's pick even when it was too unsure to apply it, or null;
|
|
187
|
+
- `confidence` and `reason`;
|
|
188
|
+
- `explain`: a sentence or two on the rule, for the person answering, when the question has one;
|
|
189
|
+
- `key`: what `--decide` takes.
|
|
190
|
+
|
|
191
|
+
**One line per file.** `prosefix --json-lines` writes nothing to the notes either. It prints one line per file, `"type": "file"` followed by the file's entry, as each file finishes, in any order. Then it prints one `"type": "summary"` line with `schema`, `prosefix`, `endpoint` and `skipped`. Each line is compact JSON in ASCII. A file that fails, including a path that does not exist, gets a line with `"status": "error"`, and the exit status stays 0. A `--report` file that cannot be written makes it 2.
|
|
192
|
+
|
|
193
|
+
**Answers.** `prosefix --decide` reads answers as JSON on stdin and stores each in the cache that its note's path uses:
|
|
194
|
+
|
|
195
|
+
```json
|
|
196
|
+
{"decisions":[
|
|
197
|
+
{"path":"/v/essay.md","key":"3b9e0c1d2a4f5e6a7b8c9d0e","choice":"licence",
|
|
198
|
+
"word":"license","options":["licence","license"]},
|
|
199
|
+
{"path":"/v/essay.md","key":"…","choice":"KEEP"},
|
|
200
|
+
{"path":"/v/notes.md","key":"…","choice":{"text":"licensed"}}]}
|
|
201
|
+
```
|
|
202
|
+
|
|
203
|
+
`choice` is one of the options, `"KEEP"` to keep the text as written, or `{"text": …}` for your own words. It prints `{"written": 3, "caches": [...]}`. Malformed input prints `{"error": "…"}`, stores nothing and exits 2. The next run with the cache applies the answers, for example `prosefix --json-lines --llm cached /v/essay.md`.
|
|
204
|
+
|
|
205
|
+
One answer can change the sentence of another question in the same note, and so that question's key. `word` is the text at the question's `start`:`end` in `output`. With `word` and `options`, prosefix carries such an answer over: an answer the run did not use moves to the one open question in the same note with the same word and options, and the note runs again, up to three times. An answer gets one chance to move: the next run of its note, normally the cached run right after `--decide`. An answer can also raise a question about the word it put in (`licence`, once chosen over `license`); prosefix answers that question `KEEP`.
|
|
206
|
+
|
|
207
|
+
Known limits: an answer to a proofix compound question applies to every occurrence of that form. An answer whose edit overlaps a stylefix edit loses to it and is dropped without notice. An answer without `word` and `options` is not carried over.
|
|
208
|
+
|
|
209
|
+
**Setup.** Three commands print one JSON object each, for a plugin's setup screen:
|
|
210
|
+
|
|
211
|
+
- `prosefix --doctor --json`: `schema`, the `prosefix` and `python` versions, each tool (`name`, `found`, `version`, `path`, `adds`, `fix`), the endpoint (`found`, `url`, `model`, `source`, `error`), `config_file` and `settings_file` (null when there is none). `fix` is a Homebrew command, with Homebrew's full path when it is found.
|
|
212
|
+
- `prosefix --check-endpoint --json [--url URL] [--model NAME]`: tests the endpoint and gives `ok`, `url`, `model`, `models`, `model_info`, `latency_ms` and `error`. `model_info` lists each model's `id` and `created` (Unix seconds, or null) in the server's order. It exits 1 when the test fails.
|
|
213
|
+
- `prosefix --setup --url URL [--model NAME] [--thinking-switch] --json`: tests the endpoint and, only if the test passes, writes `~/.config/prosefix/config.toml` with mode 0600. It gives `ok`, `written`, `url`, `model` and `error`, and exits 1 when nothing was written.
|
|
214
|
+
|
|
215
|
+
`--key-stdin` reads the API key from the first line of stdin; prosefix never prints it. It works only with `--check-endpoint --json` and `--setup --url … --json`, and `--thinking-switch` only with `--setup --url`; prosefix refuses them elsewhere, with exit status 2. Without `--key-stdin`, a `--url` equal to the one saved in prosefix's config file uses the saved key (`api_key`, or `api_key_env` by name), timeout and thinking switch, so a change of model keeps them. Another URL gets no key. The details are in the man page (`man prosefix`, or `man/prosefix.1` in the source).
|
|
177
216
|
|
|
178
217
|
## License
|
|
179
218
|
|
|
@@ -17,7 +17,7 @@ Before: We recieved the the new colour scheme -- the teams programme , which co
|
|
|
17
17
|
After: We received the new colour scheme – the teams programme, which covers analysis, design and testing.
|
|
18
18
|
```
|
|
19
19
|
|
|
20
|
-
(A British draft, kept British, with the tools installed and no model. Words that depend on meaning, such as licence and license, are listed for review until a model decides them.)
|
|
20
|
+
(A British draft, kept British, with the tools installed and no model. Words that depend on meaning, such as licence and license, are listed for review until a model decides them; see [Questions without a model](#first-run).)
|
|
21
21
|
|
|
22
22
|
## Install
|
|
23
23
|
|
|
@@ -33,7 +33,7 @@ Without Homebrew, install the tools you want. prosefix runs every tier whose req
|
|
|
33
33
|
| [Vale](https://vale.sh) (`brew install vale`) | `variety`, `guide`, `ambiguous`, `numbers` | `serial-comma`, `abbreviations`, `punctuation`, and all of the proof pass |
|
|
34
34
|
| [LanguageTool](https://languagetool.org) (`brew install languagetool`) | `mechanical`, `adjudicated` | `hygiene`, `basics`, `compounds`, `commas` |
|
|
35
35
|
| [typos](https://github.com/crate-ci/typos) (`brew install typos-cli`) | `typos` | everything else |
|
|
36
|
-
| a model | decisions that need judgement, `commas` | rule-based tiers; undecided items are listed for review |
|
|
36
|
+
| a model | decisions that need judgement, `commas` | rule-based tiers; undecided items are listed for review (see [Questions without a model](#first-run)) |
|
|
37
37
|
|
|
38
38
|
## First run
|
|
39
39
|
|
|
@@ -57,7 +57,9 @@ prosefix --setup # choose and test a model endpoint
|
|
|
57
57
|
prosefix --doctor # tools found or missing, the endpoint, the settings file for this directory
|
|
58
58
|
```
|
|
59
59
|
|
|
60
|
-
The endpoint comes from flags, `PROSEFIX_LLM_*` / `ADJUDICATE_LLM_*` environment variables, `~/.config/prosefix/config.toml` and `~/.config/adjudicate/config.toml`, never from a project file. Without a model,
|
|
60
|
+
The endpoint comes from flags, `PROSEFIX_LLM_*` / `ADJUDICATE_LLM_*` environment variables, `~/.config/prosefix/config.toml` and `~/.config/adjudicate/config.toml`, never from a project file. Without a model, all rule-based tiers still run.
|
|
61
|
+
|
|
62
|
+
**Questions without a model.** Some items need judgement but have a likely answer: a capitalised swap (`Color` to `Colour`), a serial comma, a number the guide may spell out, an abbreviation that may end a sentence, and a comma or full stop at a closing quote. Without a model, prosefix asks about each one whenever it can store your answer, that is, whenever it uses a decision cache. The question is listed for review, and the text is left as written. `--llm none` and `--no-cache` store nothing, so they do not ask: they apply the capitalised swap and list the others as plain review items. Before 0.3.0, only `--llm cached` asked.
|
|
61
63
|
|
|
62
64
|
### Which English
|
|
63
65
|
|
|
@@ -151,7 +153,44 @@ The tiers are `variety`, `guide`, `ambiguous`, `numbers`, `serial-comma`, `abbre
|
|
|
151
153
|
|
|
152
154
|
## JSON
|
|
153
155
|
|
|
154
|
-
`prosefix --json` prints one document, `"schema": 1`, for editors and plugins
|
|
156
|
+
`prosefix --json` prints one document, `"schema": 1`, for editors and plugins. It holds the endpoint, the capabilities skipped and an entry for each file. Each entry has the file's status, settings, `input_sha256`, a list of changes (`id`, `pass`, `check`, `start`, `end`, `line`, `before`, `after`, `reason`, `decided_by`, `confidence`, `depends_on`), review items and the full output. The settings include `target_source`, one of `flag`, `front matter`, `lang`, `project`, `detected` or `default`. They include `detected` word counts when detection ran, and `"variety_conversion": false` when no clear variety meant the variety spellings were left alone. `input_sha256` is the SHA-256 of the input as UTF-8, so a plugin can tell whether the note changed after the run. Change offsets are UTF-16 code units into the whole input file; `line` is 1-based. A change that lists `depends_on` supersedes the changes it names. `decided_by` is `rule`, `model`, `cache` or `user`; `user` marks a change made from your answer. A file with `"status": "error"` has only `path`, `status`, `reason` and `settings`.
|
|
157
|
+
|
|
158
|
+
**Settled output.** prosefix runs again on its own output until a run changes nothing. So `output` is settled: a run on it reports `unchanged`, with the same questions and keys. The review items come from that last run. This happens in every mode, so an in-place write gives the same text as `output`.
|
|
159
|
+
|
|
160
|
+
**Questions.** A review item with `options` is a question. Only a question has these fields:
|
|
161
|
+
|
|
162
|
+
- `start` and `end`: UTF-16 offsets into `output`, not into the input, left out when they cannot be placed there;
|
|
163
|
+
- `options`: the replacements on offer (keeping the text as written is always possible, and never listed);
|
|
164
|
+
- `suggestion`: the model's pick even when it was too unsure to apply it, or null;
|
|
165
|
+
- `confidence` and `reason`;
|
|
166
|
+
- `explain`: a sentence or two on the rule, for the person answering, when the question has one;
|
|
167
|
+
- `key`: what `--decide` takes.
|
|
168
|
+
|
|
169
|
+
**One line per file.** `prosefix --json-lines` writes nothing to the notes either. It prints one line per file, `"type": "file"` followed by the file's entry, as each file finishes, in any order. Then it prints one `"type": "summary"` line with `schema`, `prosefix`, `endpoint` and `skipped`. Each line is compact JSON in ASCII. A file that fails, including a path that does not exist, gets a line with `"status": "error"`, and the exit status stays 0. A `--report` file that cannot be written makes it 2.
|
|
170
|
+
|
|
171
|
+
**Answers.** `prosefix --decide` reads answers as JSON on stdin and stores each in the cache that its note's path uses:
|
|
172
|
+
|
|
173
|
+
```json
|
|
174
|
+
{"decisions":[
|
|
175
|
+
{"path":"/v/essay.md","key":"3b9e0c1d2a4f5e6a7b8c9d0e","choice":"licence",
|
|
176
|
+
"word":"license","options":["licence","license"]},
|
|
177
|
+
{"path":"/v/essay.md","key":"…","choice":"KEEP"},
|
|
178
|
+
{"path":"/v/notes.md","key":"…","choice":{"text":"licensed"}}]}
|
|
179
|
+
```
|
|
180
|
+
|
|
181
|
+
`choice` is one of the options, `"KEEP"` to keep the text as written, or `{"text": …}` for your own words. It prints `{"written": 3, "caches": [...]}`. Malformed input prints `{"error": "…"}`, stores nothing and exits 2. The next run with the cache applies the answers, for example `prosefix --json-lines --llm cached /v/essay.md`.
|
|
182
|
+
|
|
183
|
+
One answer can change the sentence of another question in the same note, and so that question's key. `word` is the text at the question's `start`:`end` in `output`. With `word` and `options`, prosefix carries such an answer over: an answer the run did not use moves to the one open question in the same note with the same word and options, and the note runs again, up to three times. An answer gets one chance to move: the next run of its note, normally the cached run right after `--decide`. An answer can also raise a question about the word it put in (`licence`, once chosen over `license`); prosefix answers that question `KEEP`.
|
|
184
|
+
|
|
185
|
+
Known limits: an answer to a proofix compound question applies to every occurrence of that form. An answer whose edit overlaps a stylefix edit loses to it and is dropped without notice. An answer without `word` and `options` is not carried over.
|
|
186
|
+
|
|
187
|
+
**Setup.** Three commands print one JSON object each, for a plugin's setup screen:
|
|
188
|
+
|
|
189
|
+
- `prosefix --doctor --json`: `schema`, the `prosefix` and `python` versions, each tool (`name`, `found`, `version`, `path`, `adds`, `fix`), the endpoint (`found`, `url`, `model`, `source`, `error`), `config_file` and `settings_file` (null when there is none). `fix` is a Homebrew command, with Homebrew's full path when it is found.
|
|
190
|
+
- `prosefix --check-endpoint --json [--url URL] [--model NAME]`: tests the endpoint and gives `ok`, `url`, `model`, `models`, `model_info`, `latency_ms` and `error`. `model_info` lists each model's `id` and `created` (Unix seconds, or null) in the server's order. It exits 1 when the test fails.
|
|
191
|
+
- `prosefix --setup --url URL [--model NAME] [--thinking-switch] --json`: tests the endpoint and, only if the test passes, writes `~/.config/prosefix/config.toml` with mode 0600. It gives `ok`, `written`, `url`, `model` and `error`, and exits 1 when nothing was written.
|
|
192
|
+
|
|
193
|
+
`--key-stdin` reads the API key from the first line of stdin; prosefix never prints it. It works only with `--check-endpoint --json` and `--setup --url … --json`, and `--thinking-switch` only with `--setup --url`; prosefix refuses them elsewhere, with exit status 2. Without `--key-stdin`, a `--url` equal to the one saved in prosefix's config file uses the saved key (`api_key`, or `api_key_env` by name), timeout and thinking switch, so a change of model keeps them. Another URL gets no key. The details are in the man page (`man prosefix`, or `man/prosefix.1` in the source).
|
|
155
194
|
|
|
156
195
|
## License
|
|
157
196
|
|