Repository navigation
Description
Problem
plugins/typos-format/hooks/typos-format.sh renders residual (non-applied) findings using only corrections[0], in the sentence form should be "X".
Upstream typos returns a correction list. Where that list has more than one entry, typos itself treats the finding as not safely fixable — typos -w refuses to apply it. The hook therefore presents a finding the tool declines to act on as a single definite correction, which reads as an instruction to the agent to make an edit typos deliberately would not.
The plugin's own README already documents the distinction:
Residual findings — an entry with no known correction ... or one with more than one candidate correction — surface as advisory context, never auto-applied.
So the display contradicts the documented model.
Evidence
Measured against real typos:
- 14/14 ordinary English typos were single-candidate and auto-fixed.
- 4/4 observed false positives were multi-candidate:
ba->["by","be"],mis->["miss","mist"]. Both were refused bytypos -w.
Marking multi-candidate findings removes 100% of observed false positives at zero true-positive cost.
The test suite has no residual-rendering assertion at all, which is why this shipped.
Proposed change
In the classifier jq in plugins/typos-format/hooks/typos-format.sh, add a corrs helper beside the existing corr1, and render residual findings with more than one candidate as ambiguous rather than definite:
" \"\(tok)\" (line \(.line_num // 0)) should be \(if (.corrections|length) > 1 then "\(corrs) (ambiguous — typos will not auto-correct this)" else "\"\(corrs)\"" end)."
The applied renders stay on corr1: typos -w only ever produces an applied correction from a single-candidate finding, so corr1 is exact there and must not change.
Also in scope, same file family: plugins/typos-format/hooks/hooks.json carries "statusMessage": "Fixing typos...". The default configuration is report-only and never writes, so the string misdescribes what the hook does. It should read "Checking spelling...".
Acceptance criteria
- A multi-candidate residual renders as
"ba" (line 3) should be by or be (ambiguous — typos will not auto-correct this). - A single-candidate residual still renders as
"recieve" (line 5) should be "receive". - The
corrections == nullarm ("is disallowed, no known correction") is unchanged. - The applied-correction renders are untouched and still use
corr1. typos-format.test.shgains an assertion covering the multi-candidate residual render that fails against the pre-change code.hooks.jsonstatusMessagereadsChecking spelling....
Activity