|
| 1 | +amends "package://github.com/jdx/hk/releases/download/v1.51.0/hk@1.51.0#/Config.pkl" |
| 2 | + |
| 3 | +import "package://github.com/jdx/hk/releases/download/v1.51.0/hk@1.51.0#/Builtins.pkl" |
| 4 | + |
| 5 | +// https://hk.jdx.dev/configuration.html |
| 6 | + |
| 7 | +walk_ignore = true |
| 8 | + |
| 9 | +local linters = new Mapping<String, Step> { |
| 10 | + ["ruff"] = (Builtins.ruff) { |
| 11 | + exclude = List("**/.agents/**") |
| 12 | + check = "uv run ruff check --force-exclude {{ files }}" |
| 13 | + fix = "uv run ruff check --force-exclude --fix {{ files }}" |
| 14 | + } |
| 15 | + ["oxlint"] = (Builtins.ox_lint) { |
| 16 | + check = "bun x oxlint --deny-warnings {{ files }}" |
| 17 | + fix = "bun x oxlint --deny-warnings --fix {{ files }}" |
| 18 | + } |
| 19 | + ["ghalint-action"] = Builtins.ghalint_action |
| 20 | + ["ghalint-workflow"] = (Builtins.ghalint_workflow) { |
| 21 | + check = |
| 22 | + #""" |
| 23 | + tmp="$(mktemp -d)" |
| 24 | + trap 'rm -rf "$tmp"' EXIT |
| 25 | + tar -cf - -- {{ files }} | tar -xf - -C "$tmp" |
| 26 | + cd "$tmp" |
| 27 | + ghalint run |
| 28 | + """# |
| 29 | + } |
| 30 | + ["actionlint"] = (Builtins.actionlint) { |
| 31 | + glob = |
| 32 | + List( |
| 33 | + ".github/workflows/*.yml", |
| 34 | + ".github/workflows/*.yaml", |
| 35 | + ) |
| 36 | + } |
| 37 | + ["betterleaks"] = (Builtins.betterleaks) { |
| 38 | + exclude = List("users/o/thaw/thaw.json") |
| 39 | + } |
| 40 | + ["gitleaks"] = (Builtins.gitleaks) { |
| 41 | + check = |
| 42 | + #""" |
| 43 | + root="$PWD" |
| 44 | + tmp="$(mktemp -d)" |
| 45 | + trap 'rm -rf "$tmp"' EXIT |
| 46 | + tar -cf - -- {{ files }} | tar -xf - -C "$tmp" |
| 47 | + cd "$tmp" |
| 48 | + gitleaks dir --redact --config "$root/.github/.gitleaks.toml" --verbose --no-banner . |
| 49 | + """# |
| 50 | + } |
| 51 | + ["shellcheck"] = (Builtins.shellcheck) { |
| 52 | + exclude = List("**/skills/**") |
| 53 | + } |
| 54 | + ["pyrefly"] { |
| 55 | + glob = List("pyproject.toml") |
| 56 | + exclude = List("**/.agents/**") |
| 57 | + workspace_indicator = "pyproject.toml" |
| 58 | + check = "sh -c 'cd \"{{ workspace }}\" && uv run pyrefly check --preset=all'" |
| 59 | + } |
| 60 | + ["validate-skills"] { |
| 61 | + glob = List("skills/*/SKILL.md") |
| 62 | + check = |
| 63 | + "bash -c 'for dir in skills/*/; do uvx --from skills-ref agentskills validate \"$dir\"; done'" |
| 64 | + } |
| 65 | +} |
| 66 | + |
| 67 | +local formatters = new Mapping<String, Step> { |
| 68 | + ["pkl-format"] = (Builtins.pkl_format) { |
| 69 | + glob = List("*.pkl", "**/*.pkl") |
| 70 | + } |
| 71 | + ["ruff-format"] = (Builtins.ruff_format) { |
| 72 | + check_diff = "uv run ruff format --quiet --force-exclude --diff {{ files }}" |
| 73 | + fix = "uv run ruff format --quiet --force-exclude {{ files }}" |
| 74 | + } |
| 75 | + ["shfmt"] = Builtins.shfmt |
| 76 | + ["oxfmt"] = (Builtins.oxfmt) { |
| 77 | + exclude = List("*.toml") |
| 78 | + check = "bun x oxfmt --check {{ files }}" |
| 79 | + check_list_files = "bun x oxfmt --list-different {{ files }}" |
| 80 | + fix = "bun x oxfmt --write {{ files }}" |
| 81 | + } |
| 82 | + // tombi --diff is ANSI stderr, not git-applyable; use plain check + fix |
| 83 | + ["tombi-format"] = (Builtins.tombi_format) { |
| 84 | + check_diff = null |
| 85 | + check = "tombi format --check {{ files }}" |
| 86 | + fix = "tombi format {{ files }}" |
| 87 | + } |
| 88 | +} |
| 89 | + |
| 90 | +local allSteps = (formatters) { |
| 91 | + for (name, step in linters) { |
| 92 | + [name] = step |
| 93 | + } |
| 94 | +} |
| 95 | + |
| 96 | +hooks { |
| 97 | + ["pre-commit"] { |
| 98 | + fix = true |
| 99 | + stash = "git" |
| 100 | + steps = allSteps |
| 101 | + } |
| 102 | + // formatters only — `just fmt` / `hk fix --all` |
| 103 | + ["fix"] { |
| 104 | + fix = true |
| 105 | + steps = formatters |
| 106 | + } |
| 107 | + // linters only — `just lint` / `hk check --all` |
| 108 | + ["check"] { |
| 109 | + steps = linters |
| 110 | + } |
| 111 | +} |
0 commit comments