Repository navigation
feat(builtins): classify command effects - #1167
Conversation
|
Important Review skippedAuto reviews are disabled on base/target branches other than the default branch. Please check the settings in the CodeRabbit UI or the βοΈ Run configurationConfiguration used: Repository YAML (base), Central YAML (inherited), Organization UI (inherited) Review profile: CHILL Plan: Pro Plus Run ID: You can disable this status message by setting the Use the checkbox below for a quick retry:
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. Comment |
Greptile SummaryThis PR adds generated effect metadata to builtin commands and validates complete effect coverage during generation.
Confidence Score: 5/5The PR appears safe to merge. No blocking failure remains. Important Files Changed
Reviews (6): Last reviewed commit: "feat(builtins): classify command effects" | Re-trigger Greptile |
1b1aea7 to
b8dcd03
Compare
d7b71ae to
d4e9174
Compare
d4e9174 to
25421e2
Compare
25421e2 to
cfa662a
Compare
cfa662a to
5c91143
Compare
|
Too many files changed for review (146 files, 100 file limit). Bypass the limit by tagging |
5c91143 to
30a8600
Compare
30a8600 to
bf82639
Compare
6e91f9f to
f616d0b
Compare
f616d0b to
6594b1e
Compare
6594b1e to
e163ca0
Compare
e163ca0 to
438ba8e
Compare
82eadce to
76ce0ea
Compare
76ce0ea to
e57f58c
Compare
e57f58c to
d8a23e6
Compare
Instruction counts
2 benchmark(s) above the 1% gate: Only instruction counts gate. Wall clock is shown for context β on identical hardware it moves 4-20% run to run. Measured by tak β instruction-counted CLI benchmarks, stored in this repository's git notes.
|
d8a23e6 to
d41d593
Compare
d41d593 to
f6ee638
Compare
There was a problem hiding this comment.
Cursor Bugbot has reviewed your changes and found 1 potential issue.
β Bugbot Autofix is OFF. To automatically fix reported issues with cloud agents, enable autofix in the Cursor dashboard.
Reviewed by Cursor Bugbot for commit f6ee638. Configure here.
## Summary - add normalized diagnostics with step, tool, severity, message, path, range, rule, help URL, and optional fix data - add first-party SARIF, Cargo JSON, ESLint JSON, and GCC-style parsers with deduplication and parse warnings - preserve raw step output alongside normalized diagnostics in JSON and JSONL results - add `--sarif <PATH>` export independently of the selected human or structured output format ## Stack Depends on #1167 (`feat(builtins): classify command effects`). This is layer 5 of the agent-native hk stack. ## Test evidence - `cargo fmt --check` - `cargo test diagnostics::tests` - `cargo test cli::tests::test_subcommands_are_sorted` - `cargo clippy --quiet -- -D warnings` with local-only allowances for unrelated Rust 1.97 lints already present on `main` - `mise run build` - `mise run test:bats test/diagnostics.bats` - `mise run render` ## Rollout notes Diagnostics are opt-in per step through `diagnostic_format`, so existing output behavior is unchanged. A parser failure is represented as a warning and never removes the raw command output. SARIF export writes a standard 2.1.0 file and does not add an HTTP service or uploader. *AI-assisted β Tool: Codex; model: unavailable/unavailable; version: unavailable.* <!-- CURSOR_SUMMARY --> --- > [!NOTE] > **Medium Risk** > Touches hook execution, structured emit paths, and file I/O on every run when `--sarif` is set; behavior is opt-in per step but SARIF write failures can surface after hook failures. > > **Overview** > Adds **opt-in structured diagnostics** for hook steps and a **`--sarif <PATH>`** export path on `check`, `fix`, `run`, and git-hook entrypoints (documented in CLI help and usage specs). > > Steps can set **`diagnostic_format`** (`sarif`, `cargo-json`, `eslint-json`, `gcc`) and optional **`diagnostic_tool`** in `hk.pkl`. Check output is parsed into a shared **`Diagnostic`** model (severity, locations, rules, help URLs, fixes) with deduplication and **parse warnings** when input is malformedβraw command output is still kept in JSON/JSONL results. > > **`--sarif`** writes SARIF 2.1.0 from aggregated diagnostics regardless of human vs machine output format, including empty reports on no-op or preflight failures. A separate **`diagnostic_output_by_step`** buffer keeps check-first and cancelled-run diagnostics available for structured output and human summaries without letting a later successful fixer hide the original failure text. > > <sup>Reviewed by [Cursor Bugbot](https://cursor.com/bugbot) for commit f8a648e. Bugbot is set up for automated code reviews on this repo. Configure [here](https://www.cursor.com/dashboard/bugbot).</sup> <!-- /CURSOR_SUMMARY --> <!-- This is an auto-generated comment: release notes by coderabbit.ai --> ## Summary by CodeRabbit * **New Features** * Added `--sarif <PATH>` support to `check`, `fix`, and hook-running commands. * Export normalized diagnostics as SARIF, including locations, severity, rules, help links, and fixes. * Added support for SARIF, Cargo JSON, ESLint JSON, and GCC diagnostic formats. * Deduplicate diagnostics and report warnings for malformed or unrecognized input. * **Bug Fixes** * Improved diagnostic preservation and error reporting during failed, skipped, cancelled, and fixer runs. * **Documentation** * Documented SARIF output support across applicable CLI commands. <!-- end of auto-generated comment: release notes by coderabbit.ai -->
This MR contains the following updates: | Package | Type | Update | Change | |---|---|---|---| | [hk](https://github.com/jdx/hk) | tools | minor | `1.54.1` β `1.55.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.55.0`](https://github.com/jdx/hk/blob/HEAD/CHANGELOG.md#1550---2026-08-11) [Compare Source](jdx/hk@v1.54.1...v1.55.0) ##### π Features - **(agent)** generate coding-agent integrations by [@​jdx](https://github.com/jdx) in [#​1171](jdx/hk#1171) - **(builtins)** add kingfisher secret scanner by [@​thoroc](https://github.com/thoroc) in [#​1160](jdx/hk#1160) - **(builtins)** classify command effects by [@​jdx](https://github.com/jdx) in [#​1167](jdx/hk#1167) - **(check)** add normalized diagnostics and SARIF by [@​jdx](https://github.com/jdx) in [#​1168](jdx/hk#1168) - **(mcp)** expose hk to coding agents by [@​jdx](https://github.com/jdx) in [#​1169](jdx/hk#1169) - **(mcp)** add interactive hk dashboard by [@​jdx](https://github.com/jdx) in [#​1170](jdx/hk#1170) - **(run)** add agent-friendly execution scoping by [@​jdx](https://github.com/jdx) in [#​1162](jdx/hk#1162) - **(run)** add structured execution results by [@​jdx](https://github.com/jdx) in [#​1163](jdx/hk#1163) - **(step)** add command effect safety by [@​jdx](https://github.com/jdx) in [#​1166](jdx/hk#1166) ##### π Bug Fixes - **(check)** exclude deleted paths from ref checks by [@​jdx](https://github.com/jdx) in [#​1177](jdx/hk#1177) - **(docs)** keep search modal above site navigation by [@​jdx](https://github.com/jdx) in [#​1188](jdx/hk#1188) - **(step)** support argv prefixes for structured commands by [@​jdx](https://github.com/jdx) in [#​1175](jdx/hk#1175) ##### π§ͺ Testing - **(init)** decouple agent docs assertion from releases by [@​jdx](https://github.com/jdx) in [#​1187](jdx/hk#1187) ##### π¦οΈ Dependency Updates - lock file maintenance by [@​renovate\[bot\]](https://github.com/renovate\[bot]) in [#​1151](jdx/hk#1151) - simplify cargo version requirements by [@​jdx](https://github.com/jdx) in [#​1161](jdx/hk#1161) - lock file maintenance by [@​renovate\[bot\]](https://github.com/renovate\[bot]) in [#​1173](jdx/hk#1173) - update zizmorcore/zizmor-action action to v0.6.2 by [@​renovate\[bot\]](https://github.com/renovate\[bot]) in [#​1180](jdx/hk#1180) - update jdx/mise-action action to v4.2.4 by [@​renovate\[bot\]](https://github.com/renovate\[bot]) in [#​1179](jdx/hk#1179) - update anthropics/claude-code-action action to v1.0.184 by [@​renovate\[bot\]](https://github.com/renovate\[bot]) in [#​1178](jdx/hk#1178) - update dependency [@​testing-library/jest-dom](https://github.com/testing-library/jest-dom) to v7 by [@​renovate\[bot\]](https://github.com/renovate\[bot]) in [#​1182](jdx/hk#1182) - update dependency jsdom to v30 by [@​renovate\[bot\]](https://github.com/renovate\[bot]) in [#​1183](jdx/hk#1183) - update dependency typescript to v7 by [@​renovate\[bot\]](https://github.com/renovate\[bot]) in [#​1184](jdx/hk#1184) - update jdx/mise-action action to v4.2.4 by [@​renovate\[bot\]](https://github.com/renovate\[bot]) in [#​1181](jdx/hk#1181) ##### New Contributors - [@​thoroc](https://github.com/thoroc) made their first contribution in [#​1160](jdx/hk#1160) </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=-->
hk 1.55.0 (jdx/hk#1167) moved the builtins' argv under a CommandSpec wrapper (command + effect), so the check/fix/check_list_files amends that reached for `super.argv` failed with "Cannot find property argv in object of type CommandSpec". Nest the mise-prefix argv override under `command` to match the new schema. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
hk 1.55.0 (jdx/hk#1167) moved the builtins' argv under a CommandSpec wrapper (command + effect), so the check/fix/check_list_files amends that reached for `super.argv` failed with "Cannot find property argv in object of type CommandSpec". Nest the mise-prefix argv override under `command` to match the new schema. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
hk 1.55.0 (jdx/hk#1167) moved the builtins' argv under a CommandSpec wrapper (command + effect), so the check/fix/check_list_files amends that reached for `super.argv` failed with "Cannot find property argv in object of type CommandSpec". Nest the mise-prefix argv override under `command` to match the new schema. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>

Summary
Builtins.pklboundary so overrides replace both the command and its safety claimcheck,check_list_files,check_diff, orfixcommand lacks an effectStack
Depends on #1166 (
feat(step): add command effect safety). This is layer 4 of the agent-native hk stack.Test evidence
python3 -m py_compile scripts/gen_builtins.pymise exec ruff@0.15.20 -- ruff check scripts/gen_builtins.pymise exec ruff@0.15.20 -- ruff format --check scripts/gen_builtins.pymise run pkl:gen(includes 100% effect-coverage validation)mise run buildmise run test:bats test/builtin_effects.batsmise run test:bats test/builtins_tests.batswas attempted locally; catalog loading and effect wrapping succeeded, while 27 tool executions failed because this host lacks configured Node, Ruby, or Java runtimes and one network-dependent zizmor check timed out. CI has the project toolchain and remains authoritative for the complete catalog.Rollout notes
Builtin consumers receive explicit effects automatically. A user override such as replacing
Builtins.trailing_whitespace.check_diffwith a string becomes unknown rather than inheriting the builtin's read claim. No builtin is marked destructive because current builtin commands only inspect or update recreatable/project state.AI-assisted β Tool: Codex; model: unavailable/unavailable; version: unavailable.
Note
Medium Risk
Large mechanical change across 100+ builtin modules; misclassified
readvswritecould block or allow the wrong commands under safe mode, though generation enforces complete coverage.Overview
Builtin commands now declare safety effects so hk can reason about read-only vs mutating steps (e.g.
--safe, plan JSON).Across the builtin catalog,
check,check_list_files,check_diff, andfixare no longer bare strings orCommandobjectsβthey useConfig.CommandSpecwitheffect = "read"for typical linters/format checks andeffect = "write"for fixers and checks that compile, sync, or write caches (cargo, tsc, vale, rubocop, etc.). No builtins are markeddestructive.scripts/gen_builtins.pyrunsvalidate_effect_coverage()after generatingBuiltins.pkl, evaluating the catalog as JSON and erroring if any exposed command field lacks a valid effect. Deprecated builtin aliases now re-export the canonical builtin directly instead of re-importing the module path.test/builtin_effects.batsasserts plan output includes per-step effects, safe mode runs a read builtin, and overriding a builtin command withoutCommandSpecsurfaces an unknown effect instead of inheriting the builtinβs read claim.Reviewed by Cursor Bugbot for commit c77afc6. Bugbot is set up for automated code reviews on this repo. Configure here.