Skip to content

feat(pkl): persist packages for offline evaluation - #1199

Merged
jdx merged 3 commits into
mainfrom
codex/adopt-pklr-package-cache
Aug 12, 2026
Merged

jdx merged 3 commits into
mainfrom
codex/adopt-pklr-package-cache

Conversation

@jdx

@jdx jdx commented Aug 12, 2026 •

Copy link
Copy Markdown
Owner

Summary

  • persist pklr package downloads under ~/.cache/pklr by default
  • add HK_PKL_CACHE_DIR to override the persistent package cache location
  • add HK_PKL_OFFLINE=1 for deterministic network-free Pkl evaluation

Motivation

hk caches its fully evaluated configuration, so unchanged hooks normally avoid package downloads. A config edit, hk upgrade, cache cleanup, or ephemeral hk cache still forces pklr to fetch the pinned package again. That can block local commits during a GitHub outage.

With the persistent pklr cache, a package downloaded during any prior evaluation remains available even after hk's resolved-config cache is invalidated. Offline mode fails immediately with the missing package URL and cache location instead of attempting the network.

This addresses discussion #1198.

Dependency status

pklr 1.4.0 was published by jdx/pklr#154, and Cargo.lock now resolves to that release. The manifest remains at the lowest compatible requirement, pklr = "1".

Validation

  • mise run pkl:gen
  • cargo check --locked
  • cargo test --locked (254 passed)
  • git diff --check

AI-assisted β€” Tool: Codex; model: unavailable/unavailable; version: unavailable.

Summary by CodeRabbit

  • New Features

    • Added HK_PKL_CACHE_DIR to configure the built-in package cache directory, defaulting to the platform’s standard cache location.
    • Added HK_PKL_OFFLINE to disable network access while continuing to use cached packages.
    • Offline mode supports common truthy environment values.
  • Documentation

    • Documented the new environment variables and their usage.

Note

Low Risk
Scoped to pklr evaluation and env-driven cache/offline behavior; no auth or hook execution changes.

Overview
Built-in pklr now keeps downloaded Pkl packages on disk (default under the platform cache as pklr) and wires that through EvaluatorBuilder instead of the previous one-shot EvalOptions eval API. HK_PKL_CACHE_DIR overrides the cache path; HK_PKL_OFFLINE blocks network fetches while still using cached packages, with clear errors when a package is missing.

pklr is resolved to 1.4.0 in Cargo.lock for the new cache/offline support. Docs add both variables and note they are read from the environment before hk.pkl is evaluated (not configurable inside hk.pkl).

Reviewed by Cursor Bugbot for commit 449c2bf. Bugbot is set up for automated code reviews on this repo. Configure here.

@coderabbitai

coderabbitai Bot commented Aug 12, 2026 •

Copy link
Copy Markdown
Contributor

Review Change Stack

No actionable comments were generated in the recent review. πŸŽ‰

ℹ️ Recent review info
βš™οΈ Run configuration

Configuration used: Repository YAML (base), Central YAML (inherited), Organization UI (inherited)

Review profile: CHILL

Plan: Pro Plus

Run ID: 7f201a3e-b332-45af-b939-746f92f24936

πŸ“₯ Commits

Reviewing files that changed from the base of the PR and between 1df62cc and 449c2bf.

β›” Files ignored due to path filters (1)
  • Cargo.lock is excluded by !**/*.lock
πŸ“’ Files selected for processing (1)
  • docs/environment_variables.md
🚧 Files skipped from review as they are similar to previous changes (1)
  • docs/environment_variables.md

πŸ“ Walkthrough

Walkthrough

The change adds HK_PKL_CACHE_DIR and HK_PKL_OFFLINE, documents both variables, and passes their values to pklr::EvaluatorBuilder during run_pklr.

Changes

PKL cache and offline configuration

Layer / File(s) Summary
Environment settings and documentation
src/env.rs, docs/environment_variables.md
Adds the cache directory setting with platform-based fallbacks. Adds the offline setting with truthy-value parsing. Documents both settings.
pklr evaluation wiring
src/config.rs
Configures pklr::EvaluatorBuilder with the cache directory and offline mode, alongside the existing HTTP client and rewrite rules.

Estimated code review effort: 2 (Simple) | ~10 minutes

Mergeability Score: βšͺ Minimal Β· up to 449c2

This PR adds persistent and optional offline package caching for Pkl evaluation; no actionable merge-blocking risk remains based on the supplied evidence.

Poem

I’m a rabbit tuning caches bright,
PKL packages rest just right.
Offline paths now hold their ground,
Clear settings pass around.
Hop, hopβ€”evaluation runs!

πŸš₯ Pre-merge checks | βœ… 5
βœ… Passed checks (5 passed)
Check name Status Explanation
Docstring Coverage βœ… Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.
Linked Issues check βœ… Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check βœ… Passed Check skipped because no linked issues were found for this pull request.
Description Check βœ… Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check βœ… Passed The title clearly summarizes the main changes: persistent pklr package caching and offline evaluation.

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❀️ Share

Comment @coderabbitai help to get the list of available commands.

@greptile-apps

greptile-apps Bot commented Aug 12, 2026 •

Copy link
Copy Markdown

Greptile Summary

The PR adds a persistent package cache and offline evaluation mode to the built-in pklr backend.

  • Configures pklr 1.4 through EvaluatorBuilder with cache and offline settings.
  • Adds HK_PKL_CACHE_DIR and HK_PKL_OFFLINE.
  • Documents platform-specific cache defaults and offline behavior.

Confidence Score: 5/5

The PR appears safe to merge.

No blocking failure remains, and the previously reported platform-dependent cache-path documentation issue has been fixed.

Important Files Changed

Filename Overview
src/config.rs Migrates embedded Pkl evaluation to EvaluatorBuilder and supplies the persistent cache directory and offline setting.
src/env.rs Adds lazily parsed environment settings for the pklr cache location and offline mode.
docs/environment_variables.md Documents the new settings and corrects the previously reported omission by listing platform-specific cache defaults.
Cargo.lock Updates the resolved pklr dependency from 1.3.0 to 1.4.0.

Reviews (4): Last reviewed commit: "docs: clarify pkl cache directory defaul..." | Re-trigger Greptile

Comment thread docs/environment_variables.md Resolved

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 2

πŸ€– Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Inline comments:
In `@docs/environment_variables.md`:
- Line 207: Update the HK_PKL_CACHE_DIR default documentation to describe the
platform-specific directory returned by dirs::cache_dir(), including the Linux
example ~/.cache/pklr, and retain the fallback path only as a fallback rather
than the unconditional default.

In `@src/config.rs`:
- Around line 748-749: Update the EvalOptions construction around
package_cache_dir and offline to match the locked pklr 1.3.0 API: either add a
reproducible dependency patch that provides these fields or remove/defer this
wiring until a compatible pklr release is available. Ensure the project compiles
with --locked without referencing unsupported EvalOptions fields.
πŸͺ„ Autofix

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
βš™οΈ Run configuration

Configuration used: Repository YAML (base), Central YAML (inherited), Organization UI (inherited)

Review profile: CHILL

Plan: Pro Plus

Run ID: acb392b2-5714-405d-a59c-f6f2ffd28ac2

πŸ“₯ Commits

Reviewing files that changed from the base of the PR and between c9cfc1f and a7a399e.

πŸ“’ Files selected for processing (3)
  • docs/environment_variables.md
  • src/config.rs
  • src/env.rs

Comment thread docs/environment_variables.md Resolved
Comment thread src/config.rs Resolved
@jdx
jdx force-pushed the codex/adopt-pklr-package-cache branch from a7a399e to 1d45f87 Compare August 12, 2026 22:18
@jdx
jdx force-pushed the codex/adopt-pklr-package-cache branch from 1d45f87 to 1df62cc Compare August 12, 2026 22:19
@github-actions

Copy link
Copy Markdown
Contributor

Instruction counts

The comparison never ran β€” an earlier step failed.

1df62cc09d35 vs `` Β· measured on the runner, not pushed to the history.

@socket-security

Copy link
Copy Markdown

Review the following changes in direct dependencies. Learn more about Socket for GitHub.

Diff Package Supply Chain
Security
Vulnerability Quality Maintenance License
Updatedcargo/​pklr@​1.3.0 ⏡ 1.4.080 -110093100100

View full report

@jdx
jdx enabled auto-merge (squash) August 12, 2026 23:51
@jdx
jdx merged commit d81981c into main Aug 12, 2026
20 of 21 checks passed
@jdx
jdx deleted the codex/adopt-pklr-package-cache branch August 12, 2026 23:54
@jdx jdx mentioned this pull request Aug 12, 2026
jdx added a commit that referenced this pull request Aug 19, 2026
### πŸš€ Features

- **(builtins)** support pinact v3 and v4 by
[@risu729](https://github.com/risu729) in
[#1195](#1195)
- **(pkl)** persist packages for offline evaluation by
[@jdx](https://github.com/jdx) in
[#1199](#1199)

### πŸ› Bug Fixes

- **(builtins)** preserve file argument boundaries by
[@jdx](https://github.com/jdx) in
[#1194](#1194)
- **(config)** allow steps to include binary files by
[@jdx](https://github.com/jdx) in
[#1190](#1190)
- **(hook)** preserve worktree root for scoped steps by
[@jdx](https://github.com/jdx) in
[#1200](#1200)
- **(pre-push)** peel annotated tags before diffing by
[@jdx](https://github.com/jdx) in
[#1197](#1197)
- **(step)** preserve condition compatibility with expr v2 by
[@jdx](https://github.com/jdx) in
[#1212](#1212)

### πŸ” Other Changes

- **(pkl)** upgrade formatter to 0.32.1 by
[@jdx](https://github.com/jdx) in
[#1203](#1203)
- Add `HK_OUTPUT_FILE` env var to control the output file location by
[@signadou](https://github.com/signadou) in
[#1204](#1204)

### πŸ“¦οΈ Dependency Updates

- update anthropics/claude-code-action action to v1.0.185 by
[@renovate[bot]](https://github.com/renovate[bot]) in
[#1191](#1191)
- update dependency vitest to v4 by
[@renovate[bot]](https://github.com/renovate[bot]) in
[#1186](#1186)
- update dependency vite to v8 by
[@renovate[bot]](https://github.com/renovate[bot]) in
[#1185](#1185)
- lock file maintenance by
[@renovate[bot]](https://github.com/renovate[bot]) in
[#1202](#1202)
- update anthropics/claude-code-action action to v1.0.190 by
[@renovate[bot]](https://github.com/renovate[bot]) in
[#1205](#1205)
- update dependency @testing-library/jest-dom to v7.0.1 by
[@renovate[bot]](https://github.com/renovate[bot]) in
[#1206](#1206)
- update rust crate shell-quote to 0.8 by
[@renovate[bot]](https://github.com/renovate[bot]) in
[#1207](#1207)
- update jdx/renovate-config digest to 75abd12 by
[@renovate[bot]](https://github.com/renovate[bot]) in
[#1208](#1208)
- update anthropics/claude-code-action action to v1.0.191 by
[@renovate[bot]](https://github.com/renovate[bot]) in
[#1209](#1209)

### New Contributors

- @signadou made their first contribution in
[#1204](#1204)

<!-- CURSOR_SUMMARY -->
---

> [!NOTE]
> **Low Risk**
> Mechanical version and documentation bump with no application source
changes in the diff; typical low-risk release packaging.
> 
> **Overview**
> **Release v1.56.0** β€” bumps the crate and CLI metadata from `1.55.0`
to `1.56.0` and adds the **1.56.0** section to `CHANGELOG.md`.
> 
> Every published `hk@…` / `v1.55.0` Pkl package URI in docs, examples,
and sample `hk.pkl` files is retargeted to **v1.56.0**. Generated usage
docs (`hk.usage.kdl`, `docs/cli/commands.json`, `docs/cli/index.md`)
pick up the new version string; `Cargo.lock` reflects the workspace
version only.
> 
> The changelog documents what ships in this tag: **pinact v3/v4**,
offline Pkl package persistence, hook/pre-push/step/config/builtins
fixes, Pkl formatter 0.32.1, **`HK_OUTPUT_FILE`**, and assorted
dependency updates β€” those behaviors are not introduced in this diff,
only recorded and versioned here.
> 
> <sup>Reviewed by [Cursor Bugbot](https://cursor.com/bugbot) for commit
3b70bac. Bugbot is set up for automated
code reviews on this repo. Configure
[here](https://www.cursor.com/dashboard/bugbot).</sup>
<!-- /CURSOR_SUMMARY -->

Co-authored-by: mise-en-dev <123107610+mise-en-dev@users.noreply.github.com>
tmeijn pushed a commit to tmeijn/dotfiles that referenced this pull request Aug 21, 2026
This MR contains the following updates:

| Package | Type | Update | Change |
|---|---|---|---|
| [hk](https://github.com/jdx/hk) | tools | minor | `1.55.0` β†’ `1.56.0` |

MR created with the help of [el-capitano/tools/renovate-bot](https://gitlab.com/el-capitano/tools/renovate-bot).

**Proposed changes to behavior should be submitted there as MRs.**

---

### Release Notes

<details>
<summary>jdx/hk (hk)</summary>

### [`v1.56.0`](https://github.com/jdx/hk/blob/HEAD/CHANGELOG.md#1560---2026-08-19)

[Compare Source](jdx/hk@v1.55.0...v1.56.0)

##### πŸš€ Features

- **(builtins)** support pinact v3 and v4 by [@&#8203;risu729](https://github.com/risu729) in [#&#8203;1195](jdx/hk#1195)
- **(pkl)** persist packages for offline evaluation by [@&#8203;jdx](https://github.com/jdx) in [#&#8203;1199](jdx/hk#1199)

##### πŸ› Bug Fixes

- **(builtins)** preserve file argument boundaries by [@&#8203;jdx](https://github.com/jdx) in [#&#8203;1194](jdx/hk#1194)
- **(config)** allow steps to include binary files by [@&#8203;jdx](https://github.com/jdx) in [#&#8203;1190](jdx/hk#1190)
- **(hook)** preserve worktree root for scoped steps by [@&#8203;jdx](https://github.com/jdx) in [#&#8203;1200](jdx/hk#1200)
- **(pre-push)** peel annotated tags before diffing by [@&#8203;jdx](https://github.com/jdx) in [#&#8203;1197](jdx/hk#1197)
- **(step)** preserve condition compatibility with expr v2 by [@&#8203;jdx](https://github.com/jdx) in [#&#8203;1212](jdx/hk#1212)

##### πŸ” Other Changes

- **(pkl)** upgrade formatter to 0.32.1 by [@&#8203;jdx](https://github.com/jdx) in [#&#8203;1203](jdx/hk#1203)
- Add `HK_OUTPUT_FILE` env var to control the output file location by [@&#8203;signadou](https://github.com/signadou) in [#&#8203;1204](jdx/hk#1204)

##### πŸ“¦οΈ Dependency Updates

- update anthropics/claude-code-action action to v1.0.185 by [@&#8203;renovate\[bot\]](https://github.com/renovate\[bot]) in [#&#8203;1191](jdx/hk#1191)
- update dependency vitest to v4 by [@&#8203;renovate\[bot\]](https://github.com/renovate\[bot]) in [#&#8203;1186](jdx/hk#1186)
- update dependency vite to v8 by [@&#8203;renovate\[bot\]](https://github.com/renovate\[bot]) in [#&#8203;1185](jdx/hk#1185)
- lock file maintenance by [@&#8203;renovate\[bot\]](https://github.com/renovate\[bot]) in [#&#8203;1202](jdx/hk#1202)
- update anthropics/claude-code-action action to v1.0.190 by [@&#8203;renovate\[bot\]](https://github.com/renovate\[bot]) in [#&#8203;1205](jdx/hk#1205)
- update dependency [@&#8203;testing-library/jest-dom](https://github.com/testing-library/jest-dom) to v7.0.1 by [@&#8203;renovate\[bot\]](https://github.com/renovate\[bot]) in [#&#8203;1206](jdx/hk#1206)
- update rust crate shell-quote to 0.8 by [@&#8203;renovate\[bot\]](https://github.com/renovate\[bot]) in [#&#8203;1207](jdx/hk#1207)
- update jdx/renovate-config digest to [`75abd12`](jdx/hk@75abd12) by [@&#8203;renovate\[bot\]](https://github.com/renovate\[bot]) in [#&#8203;1208](jdx/hk#1208)
- update anthropics/claude-code-action action to v1.0.191 by [@&#8203;renovate\[bot\]](https://github.com/renovate\[bot]) in [#&#8203;1209](jdx/hk#1209)

##### New Contributors

- [@&#8203;signadou](https://github.com/signadou) made their first contribution in [#&#8203;1204](jdx/hk#1204)

</details>

---

### Configuration

πŸ“… **Schedule**: (UTC)

- Branch creation
  - At any time (no schedule defined)
- Automerge
  - At any time (no schedule defined)

🚦 **Automerge**: Disabled by config. Please merge this manually once you are satisfied.

β™» **Rebasing**: Whenever MR becomes conflicted, or you tick the rebase/retry checkbox.

πŸ”• **Ignore**: Close this MR and you won't be reminded about this update again.

---

 - [ ] <!-- rebase-check -->If you want to rebase/retry this MR, check this box

---

This MR has been generated by [Mend Renovate](https://github.com/renovatebot/renovate).
<!--renovate-debug:eyJjcmVhdGVkSW5WZXIiOiI0My4yODguMCIsInVwZGF0ZWRJblZlciI6IjQzLjI4OC4wIiwidGFyZ2V0QnJhbmNoIjoibWFpbiIsImxhYmVscyI6WyJSZW5vdmF0ZSBCb3QiLCJhdXRvbWF0aW9uOmJvdC1hdXRob3JlZCIsImRlcGVuZGVuY3ktdHlwZTo6bWlub3IiXX0=-->
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant