# 使用 Homebrew, MacPorts, Nix, scoop 安装 hk

查看 hk 的安装路径、可执行文件、元数据以及面向 AI 代理工作流的安全说明。

## 安装

```sh
sudo av install brew:hk
```

其他安装命令:

### macOS

- Homebrew (100%):

```sh
brew install hk
```

  证据: local Homebrew formula metadata

- MacPorts (94%):

```sh
sudo port install hk
```

  证据: MacPorts ports tree: devel/hk/Portfile from https://api.github.com/repos/macports/macports-ports/git/trees/master?recursive=1

### Linux

- Nix (92%):

```sh
nix profile install nixpkgs#hk
```

  证据: nixpkgs package indexes: pkgs/by-name/hk/hk/package.nix from https://api.github.com/repos/NixOS/nixpkgs/git/trees/master?recursive=1

### Windows

- Scoop (92%):

```sh
scoop install main/hk
```

  证据: Scoop official bucket manifest trees: bucket/hk.json from https://api.github.com/repos/ScoopInstaller/Main/git/trees/master?recursive=1

## 软件包事实

- **软件包键:** brew:hk
- **软件包管理器:** Homebrew
- **版本:** 1.54.0
- **来源摘要:** Git hook and pre-commit lint manager
- **主页:** <https://hk.jdx.dev>
- **仓库:** <https://github.com/jdx/hk>
- **最后更新:** 2026-07-31T07:14:45Z
- **已生成:** 2026-08-03T19:37:03+00:00

## 可执行文件

- generate-docs (别名)
- hk (别名)

## 安装行为

- Bottle: 不可用

## 版本和新鲜度

- 页面生成时间: 2026-08-03
- 管理器版本: 1.54.0
## 项目历史与用法

hk is a Rust git-hook manager and project lint runner by jdx, designed around fast hook execution, tighter linter integration, and safe parallelism through read/write file locking.

### 项目历史

The official README describes hk as a git hook manager and project linting tool with an emphasis on performance. Its About page explains the motivation: git hooks need to be fast or developers stop using them, and naive parallel execution can break when multiple formatters or linters modify the same files.

hk's configuration model uses Apple's Pkl language through hk.pkl files. The configuration documentation describes layered sources, including built-in defaults, user-level hkrc, project config, Git config, environment variables, and CLI flags.

### 采用历史

hk is a young tool in the git-hook manager space. The GitHub repository was created in January 2025, early GitHub releases began in March 2025, and the documentation quickly oriented around global Git hook installation, per-project hk.pkl files, and integration with mise-en-place.

The input package facts show packaging through Homebrew, MacPorts, and Scoop, which is a practical footprint for a developer CLI aimed at local workstations rather than servers.

### 使用方式

The intended workflow is to install hooks globally or per repository, run hk init to create hk.pkl, and then let Git events run configured lint and fix steps. hk check and hk fix provide explicit command-line entry points for running checks outside Git hooks.

The configuration docs emphasize precedence and local overrides: hk.local.pkl is for local changes that should not be committed, while ~/.config/hk/config.pkl can hold user-wide defaults.

### 为什么软件包爱好者会关心

hk matters to package nerds because it is part of the newer wave of developer workflow CLIs that try to make local checks fast enough to keep enabled. Its differentiator is not another hook file format by itself, but the combination of Pkl configuration, built-in linter definitions, libgit2 usage, mise integration, and locking around file modification.

It also reflects a packaging trend: single-purpose Rust CLIs distributed through Homebrew, Scoop, MacPorts, and direct release binaries for developers who want one binary in their path.

### 时间线

- 2025-01-26: The jdx/hk GitHub repository was created.
- 2025-03-29: Early v0.6.x GitHub releases were published.
- 2025: hk documentation described global Git hook installation and hk.pkl project setup.
- 2026: hk documentation described pklr as the built-in Pkl evaluator and layered configuration sources.

### Related projects

- mise-en-place: jdx's environment/tool-version manager that hk documentation names as an integration point.
- pre-commit, lefthook, Husky, lint-staged: adjacent git-hook and lint-running tools in the same developer workflow category.
- Pkl: Apple's configuration language used for hk.pkl.

### 来源

- <https://api.github.com/repos/jdx/hk>
- <https://hk.jdx.dev/about.html>
- <https://hk.jdx.dev/configuration>
- <https://hk.jdx.dev/getting_started>
- <https://raw.githubusercontent.com/jdx/hk/main/README.md>
- input: source_facts.package-manager


## 安全说明

narrow executable package without higher-risk signals.

- **Geiger 风险:** 绿色 / 低
- narrow executable package without higher-risk signals


## Configuration and credential file locations

These source-backed paths show where this package keeps local settings or durable credentials. Automic Vault can use them as review targets for secret scanning, migration, and command approval.


## Configuration files

- Unix: hk.local.pkl, .config/hk.local.pkl, hk.pkl, .config/hk.pkl, ~/.config/hk/config.pkl
## 其他软件包管理器记录

- Nix - hk: normalized package name match | nixpkgs package indexes: pkgs/by-name/hk/hk/package.nix from https://api.github.com/repos/NixOS/nixpkgs/git/trees/master?recursive=1
- MacPorts - hk: normalized package name match | MacPorts ports tree: devel/hk/Portfile from https://api.github.com/repos/macports/macports-ports/git/trees/master?recursive=1
- Scoop - main/hk: normalized package name match | Scoop official bucket manifest trees: bucket/hk.json from https://api.github.com/repos/ScoopInstaller/Main/git/trees/master?recursive=1


## Combined YAML source

View the package source record on GitHub. [combined/hk.yml](https://github.com/mxcl/pkgdb/blob/main/combined/hk.yml)


## 来源

- pkg.so package database
- Geiger risk classifier
- curated configuration and credential file locations
- curated package history
- pkgdb category and tag curation
- external package-manager database matches
- cross-ecosystem install command graph
