This release overhauls global configuration handling, adds hook-level environment variables, and fixes several correctness issues in check/fix workflows.
Highlights
Overhauled global config (hkrc) -- The global user configuration has been significantly reworked. hk now supports the full Config.pkl format in hkrc files (not just UserConfig.pkl), fixing a panic when using the documented example with hooks and steps. The recommended config location is now ~/.config/hk/config.pkl, with clear "project wins" merge semantics. The legacy .hkrc.pkl paths and --hkrc flag are deprecated and will be removed in v2. Thanks @ivy! #710
Hook-level env support -- Hooks can now define environment variables that are automatically passed to all their steps, reducing duplication when multiple steps need the same variables. Step-level env takes precedence over hook-level env. #709
check_diff correctness in check mode -- Previously, steps with check_diff defined would always run the diff command first, even in check mode. This could hide non-auto-fixable errors when the diff command exited 0. The diff-first shortcut is now gated to fix mode only. Thanks @nkakouros! #717
Added
-
Hook-level
env: Define environment variables once per hook instead of repeating them on every step. Step-level env takes precedence when both define the same variable. (@jdx) #709hooks { ["pre-push"] { env { ["HK_PROFILES"] = "types" } steps = linters } }
-
Go-style diff parsing: hk now correctly handles unified diffs where the
---line has a.origsuffix (common with Go tools likegofmt -d). (@jdx, co-authored by @thejcannon) #704 -
XDG config directory support: Global configuration can now be placed at
~/.config/hk/config.pkl(or a custom path viaHK_CONFIG_DIR). (@ivy) #710 -
Config precedence documentation: A clear precedence table and hkrc merge semantics are now documented, covering built-in defaults through CLI flags. (@ivy) #701 #710
Fixed
-
end-of-file-fixer now enforces that files end with exactly one trailing newline, matching pre-commit-hooks behavior. Previously it would add a missing newline but leave multiple trailing newlines untouched. (@jdx) #708
-
pre-commit with stash no longer passes untracked files to linters as input. Untracked files were incorrectly included in the unstaged files set, causing them to be processed during
hk run pre-commit. Thanks @nkakouros! #716 -
check_diff in check mode no longer silently swallows errors. When a step defines
check_diff, hk previously ran the diff command first in all modes. If the diff command exited 0 (no auto-fixable issues), non-auto-fixable violations detected by the regularcheckcommand were hidden. The diff-first shortcut is now only used in fix mode. Thanks @nkakouros! #717 -
hkrc format support: Global config files can now use the full
Config.pklformat with hooks containing steps that havecheck,fix, andglobfields. Previously this caused a panic because hk always deserialized hkrc asUserConfig. (@ivy) #710 -
hkrc discovery path: Default hkrc discovery now correctly checks
~/.hkrc.pkland~/.config/hk/config.pkl, instead of only looking for.hkrc.pklrelative to the current directory. (@ivy) #710 -
--allflag documentation now correctly describes what the flag does. Thanks @nkakouros! #715
Deprecated
.hkrc.pkland--hkrcflag are deprecated and will be removed in hk v2. Use~/.config/hk/config.pklfor global configuration orhk.local.pklin the project root for per-project overrides. Deprecation warnings are shown when legacy paths are used. #710
New Contributors
- @ivy made their first contribution in #701
- @nkakouros made their first contribution in #716
Full Changelog: v1.36.0...v1.37.0