Gå til hovedinnhold

kapi fix

kapi fix [files...]

Run the checks 'kapi check' runs and apply the fixes they computed: the replacement that each failing finding of a name, spelling or word rule names. Each file's fixes are one change set, applied through the change service 'kapi apply' uses, so the file keeps its formatting and every byte outside the replaced words stays as it is. kapi fix previews each change set first, and a file the change service cannot write without changing other bytes is not written; its fixes are listed as not fixed.

Some findings have no automatic fix: a finding about tone or style, a rule with no replacement, words inside a code span, and words that hold a link, a formatting span or a placeholder, which the replacement would delete. kapi fix lists them as needing a rewrite. A finding that only reports stays as it is. A fix the change service refuses, such as one over words another fix also changes, is listed with the reason, and the file's other fixes land.

With no file arguments inside a project, kapi fix checks the project's declared content; naming files narrows it to those. After writing, it checks the files it wrote again and prints how many failing findings remain. The voice, profile and terms flags select what the check holds the content to, as they do for 'kapi check'. kapi fix takes no --ship: the project gate mode of 'kapi check' computes no fixes, so run 'kapi check --ship' after kapi fix.

--dry-run prints the change each file would get, as 'kapi apply --dry-run' prints it, and writes nothing. --json prints the result (kapi.fix-result/v1): the change set result of each file, the findings not fixed and the findings that need a rewrite.

Exit codes: 0 when every fix landed, 1 when a fix did not, 4 when the check did not run.

Commandfix
Groupwork
Try it

Runs in your browser against a small sample file. Edit the command before running, or press Run to execute it as shown.

kapi fix
Flags
FlagTypeDefaultDescription
--dry-run boolfalseprint the change each file would get and write nothing
--pack stringbuilt-in voice starter pack
--profile stringvoice profile name from the local store
--profile-file stringpath to a voice profile YAML
--project , -pstringpath to a kapi.yaml project recipe or its directory (auto-discovered from cwd if omitted)
--source-lang stringsource language (e.g. en, en-US; defaults to the project's source_language, else en)
--termstore stringnamed terms or terms-store path the checks read (defaults to the project terms store)
--voice boolfalsealso run the voice/style-similarity check (needs the kapi-check plugin and a profile with examples); its findings have no automatic fix
--voice-min float640.8voice-similarity cutoff (cosine, 0-1) below which a block is flagged off-voice
More examples
kapi fix docs/guide.md
kapi fix 'docs/**/*.md' --dry-run
kapi fix --json

← Back to the Command Reference