← Back to Pull requests

feat(builtins): add bun_check and bun_test #1995

Closed
unknown closed this pull request without merging on Dec 02, 2026 21:45 UTC
View on GitHub
unknown unknown commented on Dec 02, 2026 21:13 UTC
Author

Bun 1.4.5 includes a TypeScript type checker next to its test runner. This adds bun_check and bun_test builtins so Bun projects can run both from hk (requested in discussion #1867).

hooks {
  ["pre-push"] {
    steps {
      ["bun_check"] = Builtins.bun_check
      ["bun_test"] = Builtins.bun_test
    }
  }
}

  • bun_check runs bun check --no-script --no-pretty -p <tsconfig.json> for each project whose TypeScript files changed. --no-script stops a check script in package.json from replacing the type checker. Errors are parsed as diagnostics, so hk check --sarif and --json include them. It requires Bun 1.4.5 or later.

  • bun_test runs bun test, the whole suite, when any JS or TS file changes. Changed files are not passed on, because Bun treats them as test-file filters and a source-only change would match no tests. As with bun test itself, it fails if the project has no tests.

  • Neither is picked automatically by hk init, so a project with a tsconfig.json does not get both tsc and bun_check.
  • bun lint is not included: the released 1.4.5 binary rejects it (Script not found "lint").

    Validation: the bun_check, bun_test and bun_fmt step tests pass with Bun 1.4.5, and hk check passes. The full test/builtins_tests.bats run fails locally in asciidoctor, gh_actions_lock, rubocop, rubocop_server and standard_rb tests, which this change does not touch.

    AI-assisted — Tool: Claude Code; model: anthropic/claude-sonnet-5-5; version: unavailable.

    🤖 Generated with Claude Code

    <!-- CURSOR_SUMMARY -->
    ---

    [!NOTE]

    Low Risk

    Additive builtins with isolated test coverage and a test stub version bump; no changes to auth, data, or core hk execution paths.

    > Overview

    Adds two optional hk builtins for Bun 1.4.5+: Builtins.bun_check and Builtins.bun_test.

    > bun_check wires TypeScript checking to bun check --no-script --no-pretty -p on the workspace tsconfig.json, with diagnostic_format = "tsc" and step tests for pass/fail, SARIF-style diagnostics, paths with spaces, and ignoring a conflicting package.json check script.

    > bun_test runs the full bun test suite when JS/TS files change (no {{files}} filter) so source-only edits still execute tests. Includes tests for failing/passing cases and source-only selection.

    > The Bun tool stub under test/builtin_tool_stubs/bun is bumped 1.4.4 → 1.4.5 to match the new checker requirement.

    > <sup>Reviewed by Cursor Bugbot for commit 91a5299f7120f0843aa21cb0febe030f65d58ce5. Bugbot is set up for automated code reviews on this repo. Configure here.</sup>

    <!-- /CURSOR_SUMMARY -->

    <!-- This is an auto-generated comment: release notes by coderabbit.ai -->

    <!-- coderabbit-ai-generated:v1 -->

    Summary by CodeRabbit

    Chores
    Updated the Bun tooling stub from version 1.4.4 to 1.4.5. This is a maintenance-only change; no user-facing features, behavior changes, or fixes are included. The update does not change public interfaces or describe any changes to how the product works.

    <!-- end of auto-generated comment: release notes by coderabbit.ai -->

    Diff: 408 lines (+306 / -102) across 5 files Reviewer: jdx Review duration: 31m
    All Vouch review confidence checks passed
    Residual risk 0.18 = Change Risk (0.45) × (1 − Review Confidence (0.60)). Review depth and reviewer attention state are adequate.
    Model 1 · Change Risk (XGBoost)
    Score: 0.45 · 408 lines diff across 5 files
    0.45
    Model 2 · Review Depth (DistilBERT)
    Depth Score: 0.17 · 1 substantive comment(s)
    0.17
    Model 3 · Review Timing & Attention
    Session adequacy: 100% · Reviewer familiarity: 35%
    60%
    Bedrock Claude 3 · Risk Narration
    (disconnected)
    Groq
    Groq Risk Narration
    AWS Bedrock is currently disconnected. Generate high-confidence PR triage narration on-demand using Groq.
    Model 1 · Change Risk Attribution
    SHAP Weights
    Diff Size diff_size
    0.360
    Shallow Review Depth shallow_review_depth
    0.289
    Real PR Conversation Timeline
    1 comments
    "Review active on #1995"
    general weight: 0.35
    Reviewers
    Assignees
    Unassigned
    Labels
    risk: low confidence: 60.5% reviewed
    Vouch Risk Breakdown
    AI-powered review risk analysis
    Change Risk
    Change Risk · Model 1 (XGBoost)
    Predicted defect probability (0.00–1.00) based on diff churn, modified sensitive files, and author risk history.
    Score: 44.8% (MEDIUM) · Higher = larger blast radius
    44.8%
    Review Confidence
    Review Confidence · Models 2 & 3
    Scrutiny score (0.00–1.00) combining DistilBERT semantic review depth with reviewer familiarity and session dwell time.
    Score: 60.5% · Lower = rushed or shallow review
    60.5%
    Residual Risk
    Residual Risk · Core Equation
    Residual = Change × (1 − Confidence)
    Unmitigated risk surviving review. ≥ 0.65 triggers an automated re-queue to protect production.
    Score: 17.7% · Safe to merge
    17.7%
    Repository