hk 2.15.0 lets hk.pkl import hk's own modules through hk: URIs, so configs no longer need a version bump on every upgrade. hk check can now report findings as GitHub Actions annotations and GitLab Code Quality reports, and hooks can set their own jobs and hide_when_done. Each run writes per-step output files for agents and CI, and hk init --mise installs the detected linters. This release adds builtins for C#, C/C++, Clojure, Kotlin, Snakemake, API specs, reStructuredText, Python security and GitHub's Actions lockfile. It also fixes pre-push runs that update several refs, index locking during read-only runs, and Windows batching through pnpm exec/npx.
Added
-
hk:module URIs (#1912). Configs can import the modules of the hk that evaluates them, so you no longer bump a versionedpackage://URL on each upgrade. hk serves these modules from its own binary, so they work offline and never download anything.hk init,hk migrate pre-commit, the examples and the docs now generate this form:amends "hk:/Config.pkl" import "hk:/Builtins.pkl"
Single builtins are available as
hk:/builtins/<name>.pkl.package://URLs keep working, and they remain the option for pkl-lsp (0.9.0 and earlier can't resolvehk:), for plainpklwithout hk, and for shared packages that should pin one schema. The plainpklCLI can resolvehk:through the newhk readcommand, an external module reader: runpkl eval --external-module-reader 'hk=hk read' hk.pkl, or registerhk readunderevaluatorSettings.externalModuleReadersin aPklProject. -
CI-native reporting (#1938).
hk check,hk fixandhk runaccept two new flags:--github-annotationsprints a workflow command for each finding, so GitHub shows it inline on the pull request. Annotations don't need GitHub Advanced Security. A failed step with no parsed findings gets one::errorwith its output, and so does a run that fails before its hook starts. WhenGITHUB_STEP_SUMMARYis set, hk also appends a Markdown job summary with each step's status, duration and findings. With--format json/jsonl, annotations go to stderr.--gitlab-code-quality PATHwrites a Code Quality report for the merge request widget. Fingerprints don't include line numbers, so moving code doesn't make a finding look new.
- run: hk check --all --github-annotations
Findings come from steps that set
diagnostic_format, the same source as--sarif. Absolute paths inside the repository are made repository-relative. A run that fails before its hook starts now also writes the requested--sarifand--junit-xmlreports. The CI docs now cover jdx/hk-action, which installs a pinned hk and passes--github-annotationswhen the installed hk supports it (#1941). -
Per-hook
jobsandhide_when_done(#1933). A hook can limit how many of its steps run at once, or hide each step's output after it succeeds:hooks { ["pre-commit"] { jobs = 2; steps = linters } ["post-checkout"] { hide_when_done = true; steps = linters } }
A hook's value overrides the top-level
hk.pklsetting.hk.jobsgit config,HK_JOBS/HK_HIDE_WHEN_DONEand--jobsstill override it.hk validatenow warns when a hook'senvsets an hk setting such asHK_JOBS, because that env only reaches the step commands and hk never reads it. -
One output file per step (#1943). Each hook run also writes every step's output summary to
<step>.loginHK_OUTPUT_DIR, which defaults to<git-dir>/hk/output/. An agent or CI job can read one step's output without loading the whole run. Step names are percent-encoded in the file names, for examplelint/jsbecomeslint%2Fjs.log. Each run deletes.logfiles left by earlier runs, and overlapping runs take a lock, so the directory never mixes output from two runs. -
hk init --miseadds the linters' tools (#1939). Along withhk, the generatedmise.tomlnow lists each detected or selected builtin's tools atlatest, somise installinstalls everything the hooks need. Tools already inmise.tomlstay as they are, even under another backend (for exampleaqua:astral-sh/ruffcounts asruff). Language runtimes such asnode,pythonorrustare never added; hk prints themise usecommand for them instead. When a builtin step fails because its tool isn't installed, hk now ends the run with a hint such asmise use prettier shfmt shellharden. -
New builtins:
gh_actions_lockchecks that.github/workflows/actions.lockpins every action your workflows use. The check runs offline. The fix calls the GitHub API only when pins are missing, usingGH_TOKEN/GITHUB_TOKENwhen set (#1922).csharpierformats C# and MSBuild files one file at a time, without a restore or build (#1958).roslynatorruns Roslynator'sanalyze/fixon the changed.csfiles of a project or solution. It needs theRoslynator.Analyzerspackage in the project and runsdotnet restorefirst (#1957).cppcheckruns the C/C++ static analyzer.clang_format,cpp_lintandcppchecknow share a "C/C++" category in the catalogue and thehk initpicker (#1954).clj_kondolints Clojure, ClojureScript, EDN and babashka files, andcljstylechecks and fixes Clojure formatting (#1930).detektruns the detekt 1.x Kotlin analyzer and picks updetekt.ymlorconfig/detekt/detekt.ymlon top of the default rules. It is skipped on Windows (#1932).snakefmtformats Snakemake files, andsnakemakerunssnakemake --lintonce per workflow (#1956).spectrallints OpenAPI, Swagger, AsyncAPI and Arazzo files. Without a project ruleset, it uses a default one. It is skipped on Windows (#1955).banditruns the Python security linter and reads[tool.bandit]inpyproject.tomlor a.banditfile (#1931).rstcheckchecks reStructuredText files, including the code inside their code blocks (#1929).
All of these except
csharpier,cljstyleandsnakefmtsetdiagnostic_format = "gcc", so their findings appear in--sarif,--jsonand the new CI reports.roslynatordoesn't: its output isn't in a format hk parses.
Fixed
- Pre-push with several refs (#1924, reported by @Gerry9000 in #1910). When one
git pushupdated several refs, hk selected files from only the first ref, so commands such asgit push origin feat-a feat-borgit push origin :old feat-bcould push files that were never checked. hk now checks the files changed across every ref the push updates, and skips deletions. A step withrequires_ref_range = true(such asgitleakswithscan = "commits") now fails on a multi-ref push and asks you to push the refs one at a time, instead of scanning only the first range.{{from_ref}}/{{to_ref}}hold the first range. hk run pre-push --from-ref X --to-ref Yno longer waits on an open stdin (#1923, reported by @dev1952 in #1909). When both refs are given, hk doesn't read stdin, andhook_stdinis empty. Hooks run bygit pushare unaffected.- Read-only runs no longer lock or rewrite
.git/index(#1928, reported by @Gerry9000 in #1911).hk checkand hooks that don't stash or stage now read status withGIT_OPTIONAL_LOCKS=0, so they no longer collide with agit addorgit commitrunning in the same worktree. output.logcovers the whole run (#1940).HK_OUTPUT_FILE(default<git-dir>/hk/output.log) now holds every step's output summary from the latest hook run, with each step's status and no ANSI codes. Before, it held only the single failure that ended the run. Each run replaces the file, passing runs included. The file is removed when no step produced output.- Windows batching through package managers (#1935, reported by @hcoona in #1919). Commands that start with
npm,npx,pnpm,pnpxoryarn(including native.exeinstalls) are now split into batches that fitcmd.exe's 8191-character limit. Before, large runs failed withThe command line is too long. check_added_large_filesskips Git LFS files (#1934, reported by @CallumKerson in #1920). Files withfilter=lfsare no longer reported, which matches pre-commit's behavior.hadolintmatches more Dockerfile names (#1953). It now lints*.Dockerfile, lowercasedockerfilenames and Podman/BuildahContainerfilevariants. It no longer passes files in directories named likeDockerfiles.d/, or*.dockerignorefiles.- Config cache with optional imports (#1946, reported by @pawelad in #1945). hk now reloads the config when the file named by an optional import without a wildcard, such as
import* "extra.pkl", is created or deleted.
Full Changelog: v2.14.0...v2.15.0
💚 Sponsor hk
hk is built and maintained by @jdx, an open source developer at entire.io, the title sponsor of his open source work.
If hk speeds up your pre-commit loop or makes linting less painful, please consider becoming an individual or company sponsor. Your support funds ongoing development and helps keep hk fast, free, and independent.