A cluster of pre-commit correctness fixes so hk run pre-commit (and installed hooks) really only see staged files, plus a textlint builtin, a content-addressed config cache, and a docs accuracy pass.
Added
-
textlintbuiltin (@smasato) #1036. Adds textlint as a batched natural-language linter for Markdown and plain text.checkrunstextlint {{ files }},fixrunstextlint --fix {{ files }}, and it auto-suggests when.textlintrc*or a"textlint"entry inpackage.jsonis present.["textlint"] = Builtins.textlint
Fixed
-
Pre-commit is staged-only, even without stashing (@jdx) #1023. The default file selection for
pre-commitsteps now stays scoped to staged paths whenstash = false, matching the "only what you're committing" expectation instead of also picking up unstaged and untracked matches. -
Installed global pre-commit hooks pass
--staged(@jdx) #1043.hk install --globalnow generatespre-commithook commands ashk run pre-commit --from-hook --staged, so an env override likeHK_STASH=gitcan't defeat a repo-levelstash = "none"policy. Local config hooks and legacy.git/hooks/shims are unchanged. Fixes discussion #1030. -
Git string settings actually apply (@jdx) #1042. String, enum, and path settings from git config are now read via
Config::get_string, which works on the live config thatRepository::config()returns. Previously libgit2 rejected the borrow-returning read, so values likehk.stashsilently fell back to defaults even thoughhk config explainlisted git as their source. Fixes discussion #1031. -
Rename-only commits no longer bypass pre-commit (@smasato) #1035. Under the default libgit2 backend,
git mvcommits were reporting "Fetching staged files (0 files)" and skipping every step, because git2'sStatusEntry::path()returns the old path for renamed entries — which no longer exists in the worktree and got filtered out. hk now resolves the new path from the head-to-index delta forINDEX_RENAMEDentries. The shell-git porcelain parser is also fixed to consume the trailing original-path field onR/Crecords instead of misparsing it as another status entry. Regressed since rename detection was enabled in #347. -
check_firstpreferscheck_list_filesovercheck(@risu729) #1038. Restores the pre-#547 ordering for the fix-mode prepass:check_diff->check_list_files->check. For steps that define bothcheckandcheck_list_files, the prepass can now narrow the subsequentfixto just the files that need writes, taking fewer write locks and keeping<JOB_FILES>scoped to files that were actually processed. Normalhk checkstill preferscheckfirst — this only changes the fix-modecheck_firstpath. Empty platform-specific scripts are also skipped when choosing the check-first command.
Performance
- Resolved config cache shared by content (@jdx) #1044. When a
hk.pkl(and all of its imports) resolves purely from local files, the resolved-config cache now keys off content instead of the absolute config path, so byte-identical configs in different directories share one cache entry. Configs that pull in remotehttporpackageimports keep the previous path-keyed behavior since hk can't hash those.
Changed
terabumped to v2 (#1028).
Documentation
-
Docs accuracy pass (@jdx) #1022. Audits the docs against
src/env.rs,settings.toml, andpkl/Config.pkland fixes the drift. Notably:HK_STASHdefault is documented asnone(notgit),patch-fileis described as an alias ofgit,environment_variables.mdis reorganized alphabetically with previously undocumented vars added (HK_CACHE,HK_CHECK,HK_CONFIG_DIR,HK_JSON,HK_PKL_BACKEND,HK_PKL_CA_CERTIFICATES,HK_PKL_HTTP_REWRITE,HK_STASH_BACKUP_COUNT,HK_TERMINAL_PROGRESS,HK_TRACE,HK_WALK_IGNORE,HK_WARNINGS, and the env aliases fromsettings.toml),pkl_introduction.mdexamples use the realStepclass with valid pkl syntax,logging.mduses--plan(not the nonexistent--dry-run) and the correctinfodefault level, and builtin counts move to 140+. -
New vector logo (@jdx) #1041. Replaces the raster hook illustration with a stroke-based "hk" wordmark whose descender curls into a fishing hook, plus a bare hook glyph for the navbar and favicons. Scales cleanly down to 16px and to monochrome.
Full Changelog: v1.49.0...v1.50.0
💚 Sponsor hk
hk is maintained by @jdx, an open source developer for entire.io, the title sponsor of the jdx.dev open source tools including mise, aube, and more. Work on hk is funded by sponsorships.
If hk has sped up your pre-commit loop or made linting feel less painful, please consider sponsoring at jdx.dev. Sponsorships are what keep hk moving and the project independent.