Skip to content

refactor: Simplify RunType/CheckType#547

Merged
jdx merged 12 commits intojdx:mainfrom
thejcannon:jcannon/runmode
Jan 5, 2026
Merged

refactor: Simplify RunType/CheckType#547
jdx merged 12 commits intojdx:mainfrom
thejcannon:jcannon/runmode

Conversation

@thejcannon
Copy link
Copy Markdown
Contributor

@thejcannon thejcannon commented Dec 27, 2025

The usage of RunType and CheckType was confusing to me. For instance, we may be running the check_diff command but be in run_type == RunType::Check(CheckType::Check) (if we're running hk check ...).

Instead simplify by making it one toggle: RunType which matches whether we're checking or fixing. Here's how that shakes out:

  • StepJob.check_first is true if the job should (and hans't already) run check_first
  • If you want to know what kind of check job ran (in Step.run) compare against the run_cmd (E.g. run_cmd == self.check_diff.as_ref()
  • Split run_cmd into run_cmd and check_first_run_cmd so we can have different hierarchies

Overall, this should hopefully simplify things a bit, since I have some more refactors I'd like to pursue in this space.

Changed Behavior:

  • hk test now prefers check over check_diff (before it had those swapped)

Note

Streamlines execution by removing CheckType and using a single RunType toggle across the codebase.

  • Replace RunType::Check(CheckType) with RunType::{Check, Fix}; remove CheckType
  • Refactor command resolution: new check_first_cmd() and has_command_for(); run_cmd() now falls back (e.g., Fix can run check if no fix)
  • Update scheduling/skip logic to use has_command_for() and simplified RunType in hook.rs, step.rs, and step_job.rs
  • Rework check_first flow: temporarily switch job to Check, parse outputs, reset state, and avoid double-running summaries
  • Adjust error/output handling by comparing run_cmd to check_list_files/check_diff instead of enum matching
  • Update test runner to choose RunType directly; behavior change: hk test prefers check over check_diff
  • Minor test updates (e.g., add -v in test/git.bats)

Written by Cursor Bugbot for commit 7d3202b. This will update automatically on new commits. Configure here.

@thejcannon thejcannon marked this pull request as draft December 27, 2025 12:57
@thejcannon
Copy link
Copy Markdown
Contributor Author

Note the jq builtin test is due to #549 (although ideally we aren't running anything different)

@thejcannon thejcannon marked this pull request as ready for review January 1, 2026 15:44
@jdx
Copy link
Copy Markdown
Owner

jdx commented Jan 4, 2026

Bugbot run

Copy link
Copy Markdown

@cursor cursor Bot left a comment

Choose a reason for hiding this comment

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

✅ Bugbot reviewed your changes and found no bugs!

@jdx jdx merged commit 807bf46 into jdx:main Jan 5, 2026
18 checks passed
@jdx jdx mentioned this pull request Jan 5, 2026
@thejcannon thejcannon deleted the jcannon/runmode branch January 5, 2026 19:26
jdx added a commit that referenced this pull request Jan 6, 2026
## [1.29.0](https://github.com/jdx/hk/compare/v1.28.0..v1.29.0) -
2026-01-06

### 🚀 Features

- **(ghalint)** add ghalint config to hk builtin config by
[@hituzi-no-sippo](https://github.com/hituzi-no-sippo) in
[#551](#551)
- **(pinact)** add pinact config to hk builtin config by
[@hituzi-no-sippo](https://github.com/hituzi-no-sippo) in
[#552](#552)
- **(pkl)** add pkl file type by
[@hituzi-no-sippo](https://github.com/hituzi-no-sippo) in
[#571](#571)
- **(stylua)** use check_diff instead of check command by
[@hituzi-no-sippo](https://github.com/hituzi-no-sippo) in
[#563](#563)
- **(vale)** add vale config to hk builtin config by
[@hituzi-no-sippo](https://github.com/hituzi-no-sippo) in
[#554](#554)
- **(zizmor)** add zizmor config to hk builtin config by
[@hituzi-no-sippo](https://github.com/hituzi-no-sippo) in
[#550](#550)
- add rumdl config to hk builtin config by
[@hituzi-no-sippo](https://github.com/hituzi-no-sippo) in
[#541](#541)
- add selene config to hk builtin config by
[@hituzi-no-sippo](https://github.com/hituzi-no-sippo) in
[#544](#544)
- Add `fix` to `cargo_check` builtin (running `cargo fix`) by
[@thejcannon](https://github.com/thejcannon) in
[#555](#555)
- Lua file type support by
[@hituzi-no-sippo](https://github.com/hituzi-no-sippo) in
[#558](#558)
- add editorconfig-checker config to hk builtin config by
[@hituzi-no-sippo](https://github.com/hituzi-no-sippo) in
[#557](#557)
- add ryl config to hk builtin config by
[@hituzi-no-sippo](https://github.com/hituzi-no-sippo) in
[#543](#543)
- add buf_format builtin using buf cli by
[@joonas](https://github.com/joonas) in
[#565](#565)
- add buf_lint builtin using buf cli by
[@joonas](https://github.com/joonas) in
[#562](#562)
- apply check_diff output directly using git apply by
[@jdx](https://github.com/jdx) in
[#561](#561)

### 🐛 Bug Fixes

- **(ci)** pre-install nightly toolchain for cargo_check tests by
[@joonas](https://github.com/joonas) in
[#567](#567)
- **(rubocop)** fix rubocop fix command by
[@hituzi-no-sippo](https://github.com/hituzi-no-sippo) in
[#572](#572)
- Fix the `jq` builtin by [@thejcannon](https://github.com/thejcannon)
in [#533](#533)
- Fix the `rg` command in the tasks by
[@thejcannon](https://github.com/thejcannon) in
[#534](#534)
- Make `settings.toml` and `Config.pkl` agree on keys by
[@thejcannon](https://github.com/thejcannon) in
[#539](#539)
- Add `check_list_files` to `cargo_fmt` builtin by
[@thejcannon](https://github.com/thejcannon) in
[#542](#542)
- Remove `jq`'s `check` command by
[@thejcannon](https://github.com/thejcannon) in
[#549](#549)

### 🚜 Refactor

- **(ruby)** use types instead of glob for Ruby builtins by
[@hituzi-no-sippo](https://github.com/hituzi-no-sippo) in
[#564](#564)
- Simplify RunType/CheckType by
[@thejcannon](https://github.com/thejcannon) in
[#547](#547)

### 📚 Documentation

- **(config)** fix indentations in `workspace_indicator` example by
[@hituzi-no-sippo](https://github.com/hituzi-no-sippo) in
[#573](#573)

### 🧪 Testing

- Add `actionlint` test by [@thejcannon](https://github.com/thejcannon)
in [#537](#537)
- shfmt by [@thejcannon](https://github.com/thejcannon) in
[#538](#538)
- Clean up some `check_` builtin tests by
[@thejcannon](https://github.com/thejcannon) in
[#536](#536)
- Test `rustfmt` and `cargo_format` by
[@thejcannon](https://github.com/thejcannon) in
[#540](#540)
- Add tests to the mypy builtin by
[@thejcannon](https://github.com/thejcannon) in
[#560](#560)
- Add tests to the isort builtin by
[@thejcannon](https://github.com/thejcannon) in
[#559](#559)

### 📦️ Dependency Updates

- update anthropics/claude-code-action digest to 7145c3e by
[@renovate[bot]](https://github.com/renovate[bot]) in
[#545](#545)
- update rust crate serde_json to v1.0.147 by
[@renovate[bot]](https://github.com/renovate[bot]) in
[#546](#546)
- update rust crate serde_json to v1.0.148 by
[@renovate[bot]](https://github.com/renovate[bot]) in
[#569](#569)
- update rust crate tracing to v0.1.44 by
[@renovate[bot]](https://github.com/renovate[bot]) in
[#570](#570)

<!-- CURSOR_SUMMARY -->
---

> [!NOTE]
> Releases `v1.29.0` and syncs version references across the project.
> 
> - Add `1.29.0` entry to `CHANGELOG.md`
> - Update version to `1.29.0` in `Cargo.toml`, `hk.usage.kdl`, CLI docs
(`docs/cli/index.md`, `docs/cli/commands.json`), and examples
> - Replace Pkl `amends`/`import` URLs to `v1.29.0` in docs and sample
configs (e.g., `docs/*.md`, `docs/public/*.pkl`, `hk-example.pkl`,
`hk.pkl`)
> - Update init template and error help to reference `v1.29.0`
(`src/cli/init.rs`, `src/config.rs`)
> - Refresh `Cargo.lock` with minor dependency bumps
> 
> <sup>Written by [Cursor
Bugbot](https://cursor.com/dashboard?tab=bugbot) for commit
e23a13c. This will update automatically
on new commits. Configure
[here](https://cursor.com/dashboard?tab=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 Jan 9, 2026
This MR contains the following updates:

| Package | Update | Change |
|---|---|---|
| [hk](https://github.com/jdx/hk) | minor | `1.28.0` → `1.29.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.29.0`](https://github.com/jdx/hk/blob/HEAD/CHANGELOG.md#1290---2026-01-06)

[Compare Source](jdx/hk@v1.28.0...v1.29.0)

##### 🚀 Features

- **(ghalint)** add ghalint config to hk builtin config by [@&#8203;hituzi-no-sippo](https://github.com/hituzi-no-sippo) in [#&#8203;551](jdx/hk#551)
- **(pinact)** add pinact config to hk builtin config by [@&#8203;hituzi-no-sippo](https://github.com/hituzi-no-sippo) in [#&#8203;552](jdx/hk#552)
- **(pkl)** add pkl file type by [@&#8203;hituzi-no-sippo](https://github.com/hituzi-no-sippo) in [#&#8203;571](jdx/hk#571)
- **(stylua)** use check\_diff instead of check command by [@&#8203;hituzi-no-sippo](https://github.com/hituzi-no-sippo) in [#&#8203;563](jdx/hk#563)
- **(vale)** add vale config to hk builtin config by [@&#8203;hituzi-no-sippo](https://github.com/hituzi-no-sippo) in [#&#8203;554](jdx/hk#554)
- **(zizmor)** add zizmor config to hk builtin config by [@&#8203;hituzi-no-sippo](https://github.com/hituzi-no-sippo) in [#&#8203;550](jdx/hk#550)
- add rumdl config to hk builtin config by [@&#8203;hituzi-no-sippo](https://github.com/hituzi-no-sippo) in [#&#8203;541](jdx/hk#541)
- add selene config to hk builtin config by [@&#8203;hituzi-no-sippo](https://github.com/hituzi-no-sippo) in [#&#8203;544](jdx/hk#544)
- Add `fix` to `cargo_check` builtin (running `cargo fix`) by [@&#8203;thejcannon](https://github.com/thejcannon) in [#&#8203;555](jdx/hk#555)
- Lua file type support by [@&#8203;hituzi-no-sippo](https://github.com/hituzi-no-sippo) in [#&#8203;558](jdx/hk#558)
- add editorconfig-checker config to hk builtin config by [@&#8203;hituzi-no-sippo](https://github.com/hituzi-no-sippo) in [#&#8203;557](jdx/hk#557)
- add ryl config to hk builtin config by [@&#8203;hituzi-no-sippo](https://github.com/hituzi-no-sippo) in [#&#8203;543](jdx/hk#543)
- add buf\_format builtin using buf cli by [@&#8203;joonas](https://github.com/joonas) in [#&#8203;565](jdx/hk#565)
- add buf\_lint builtin using buf cli by [@&#8203;joonas](https://github.com/joonas) in [#&#8203;562](jdx/hk#562)
- apply check\_diff output directly using git apply by [@&#8203;jdx](https://github.com/jdx) in [#&#8203;561](jdx/hk#561)

##### 🐛 Bug Fixes

- **(ci)** pre-install nightly toolchain for cargo\_check tests by [@&#8203;joonas](https://github.com/joonas) in [#&#8203;567](jdx/hk#567)
- **(rubocop)** fix rubocop fix command by [@&#8203;hituzi-no-sippo](https://github.com/hituzi-no-sippo) in [#&#8203;572](jdx/hk#572)
- Fix the `jq` builtin by [@&#8203;thejcannon](https://github.com/thejcannon) in [#&#8203;533](jdx/hk#533)
- Fix the `rg` command in the tasks by [@&#8203;thejcannon](https://github.com/thejcannon) in [#&#8203;534](jdx/hk#534)
- Make `settings.toml` and `Config.pkl` agree on keys by [@&#8203;thejcannon](https://github.com/thejcannon) in [#&#8203;539](jdx/hk#539)
- Add `check_list_files` to `cargo_fmt` builtin by [@&#8203;thejcannon](https://github.com/thejcannon) in [#&#8203;542](jdx/hk#542)
- Remove `jq`'s `check` command by [@&#8203;thejcannon](https://github.com/thejcannon) in [#&#8203;549](jdx/hk#549)

##### 🚜 Refactor

- **(ruby)** use types instead of glob for Ruby builtins by [@&#8203;hituzi-no-sippo](https://github.com/hituzi-no-sippo) in [#&#8203;564](jdx/hk#564)
- Simplify RunType/CheckType by [@&#8203;thejcannon](https://github.com/thejcannon) in [#&#8203;547](jdx/hk#547)

##### 📚 Documentation

- **(config)** fix indentations in `workspace_indicator` example by [@&#8203;hituzi-no-sippo](https://github.com/hituzi-no-sippo) in [#&#8203;573](jdx/hk#573)

##### 🧪 Testing

- Add `actionlint` test by [@&#8203;thejcannon](https://github.com/thejcannon) in [#&#8203;537](jdx/hk#537)
- shfmt by [@&#8203;thejcannon](https://github.com/thejcannon) in [#&#8203;538](jdx/hk#538)
- Clean up some `check_` builtin tests by [@&#8203;thejcannon](https://github.com/thejcannon) in [#&#8203;536](jdx/hk#536)
- Test `rustfmt` and `cargo_format` by [@&#8203;thejcannon](https://github.com/thejcannon) in [#&#8203;540](jdx/hk#540)
- Add tests to the mypy builtin by [@&#8203;thejcannon](https://github.com/thejcannon) in [#&#8203;560](jdx/hk#560)
- Add tests to the isort builtin by [@&#8203;thejcannon](https://github.com/thejcannon) in [#&#8203;559](jdx/hk#559)

##### 📦️ Dependency Updates

- update anthropics/claude-code-action digest to [`7145c3e`](jdx/hk@7145c3e) by [@&#8203;renovate\[bot\]](https://github.com/renovate\[bot]) in [#&#8203;545](jdx/hk#545)
- update rust crate serde\_json to v1.0.147 by [@&#8203;renovate\[bot\]](https://github.com/renovate\[bot]) in [#&#8203;546](jdx/hk#546)
- update rust crate serde\_json to v1.0.148 by [@&#8203;renovate\[bot\]](https://github.com/renovate\[bot]) in [#&#8203;569](jdx/hk#569)
- update rust crate tracing to v0.1.44 by [@&#8203;renovate\[bot\]](https://github.com/renovate\[bot]) in [#&#8203;570](jdx/hk#570)
- lock file maintenance by [@&#8203;renovate\[bot\]](https://github.com/renovate\[bot]) in [#&#8203;553](jdx/hk#553)

</details>

---

### Configuration

📅 **Schedule**: 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 [Renovate Bot](https://github.com/renovatebot/renovate).
<!--renovate-debug:eyJjcmVhdGVkSW5WZXIiOiI0Mi43NS4xIiwidXBkYXRlZEluVmVyIjoiNDIuNzUuMSIsInRhcmdldEJyYW5jaCI6Im1haW4iLCJsYWJlbHMiOlsiUmVub3ZhdGUgQm90IiwiYXV0b21hdGlvbjpib3QtYXV0aG9yZWQiLCJkZXBlbmRlbmN5LXR5cGU6Om1pbm9yIl19-->
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.

2 participants