1
0
mirror of https://github.com/j178/prek.git synced 2026-04-25 02:11:36 +02:00
Commit Graph

1247 Commits

Author SHA1 Message Date
Jo 6f6c05e098 . 2026-02-04 15:41:36 +08:00
Shaan Majid d548c08361 Add llms.txt generation for LLM-friendly documentation (#1553)
Closes #1498 

Generates `llms.txt` and `llms-full.txt` for the documentation site.
Also generates markdown files at each path (e.g.,
`/configuration/index.md`), enabling LLMs to fetch raw markdown instead
of HTML.

As mentioned in the issue, this wasn't natively possible, since Zensical
doesn't yet support MkDocs's plugin ecosystem. I built
[llmstxt-standalone](https://github.com/shaanmajid/llmstxt-standalone)
to work as a standalone `llms.txt` generator, respecting the config for
[mkdocs-llmstxt](https://github.com/pawamoy/mkdocs-llmstxt).

- Configure llmstxt plugin in mkdocs.yml with section structure
- Add `docs-build` and `docs-compile` mise tasks
- Update CI to run llmstxt-standalone after zensical build

Note: the generated files are not served or visible when using `zensical
serve`, but will be generated and published to docs site as part of the
`publish-docs` workflow.

Preview: 
-
[llms.txt](https://gist.github.com/shaanmajid/767af572028a23ec4d0bfac2015011a5#file-llms-txt)
-
[llms-full.txt](https://gist.github.com/shaanmajid/767af572028a23ec4d0bfac2015011a5#file-llms-full-txt)

---------

Co-authored-by: Jo <10510431+j178@users.noreply.github.com>
2026-02-04 13:58:36 +08:00
wangxiaolei df0adba920 Add prek identify subcommand (#1554)
fix #1550

cargo run -- identify .gitignore Cargo.lock README.md .github/

output

```
.gitignore                                                                        
   Tags: file, non-executable, text, gitignore

Cargo.lock
   Tags: file, non-executable, text, toml, cargo-lock

README.md
  Tags: file, non-executable, text, plain-text, markdown

.github/
  Tags: directory
```

---------

Co-authored-by: Jo <10510431+j178@users.noreply.github.com>
2026-02-04 13:53:31 +08:00
An Guoli 5c64e47d6f Use BTreeSet instead of FxHashSet to ensure sequential iteration (#1548) 2026-02-03 22:43:34 +08:00
Jo b14a3c203c Detect prek installed by the standalone installer (#1545) 2026-02-03 18:29:09 +08:00
Jo 3b0ea8c92f Remove detection of cargo install source (#1544)
Just realized that
[`cargo-binstall`](https://github.com/cargo-bins/cargo-binstall) also
installs things into `~/.cargo/bin`, so there’s no (easy) way to tell
whether something was installed with `cargo install` or `cargo
binstall`.

Partially reverts #1540
2026-02-03 18:11:43 +08:00
Shaan Majid d630b38a5e Detect install source for actionable upgrade hints (#1540)
Detects how prek was installed (Homebrew or Cargo) by inspecting the
executable path, then provides actionable upgrade hints when:

- `prek self update` fails because prek wasn't installed via standalone
scripts
- `minimum_prek_version` isn't satisfied

Based largely on the approach uv implemented in
[astral-sh/uv#16838](https://github.com/astral-sh/uv/pull/16838).

Detection heuristics:
- Homebrew: path contains `/Cellar/prek/`
- Cargo: path contains `/.cargo/bin/`

Example output:
```console
error: prek was installed via an external package manager and cannot self-update.
hint: You installed prek via Homebrew. To update, run brew update && brew upgrade prek
```

See discussion in #1490 for further context.

---------

Co-authored-by: Jo <10510431+j178@users.noreply.github.com>
2026-02-03 14:48:54 +08:00
Jo bcf2ebb18c Use GlobPatterns for meta hooks files field (#1543) 2026-02-03 14:28:12 +08:00
Jo f8df4e781a Use strum derives to reduce handwritten enum parsing and display (#1541) 2026-02-03 11:29:08 +08:00
Shaan Majid 8dc7ff2550 fix(tests): use version filter in minimum_prek_version snapshots (#1539)
Replace hardcoded version `0.3.1` with `[VERSION]` placeholder using
insta's filter mechanism. This prevents test failures when the version
is bumped.
2026-02-02 20:47:32 -06:00
Shaan Majid 73e14e65d3 Revert "Allow optional upgrade hints after semicolon in minimum_prek_version" (#1538) 2026-02-03 08:34:38 +08:00
Jo 1c1af94121 Allow optional upgrade hints after semicolon in minimum_prek_version (#1536)
Closes #1490
2026-02-02 22:35:12 +08:00
Jo 5797d53c61 Add more tests for config parsing 2026-02-02 21:06:27 +08:00
Jo c405db6248 Implement serialize_yaml_scalar using serde-saphyr (#1534) 2026-02-02 20:40:34 +08:00
Jo 7950d577f7 Show precise location for config parsing error (#1530)
Finally, we can actually fix #783, big thanks to serde‑saphyr and
@bourumir-wyngs!

For this invalid config:
```yaml
repos:
  - repo: 'https://github.com/pre-commit/pre-commit-hooks'
    rev: v6.0.0
    hooks:
      - id: trailing-whitespace
      - name: end-of-file-fixer
      - id: check-yaml
      - id: check-added-large-files
```

Before:

```console
❯ prek validate-config .pre-commit-config.yaml
error: Failed to parse `.pre-commit-config.yaml`
  caused by: Invalid remote repo: missing field `id`
```

After:
```console
❯ ~/code/rust/prek/target/debug/prek validate-config .pre-commit-config.yaml
error: Failed to parse `.pre-commit-config.yaml`
  caused by: error: line 6 column 9: missing field `id` at line 6, column 9
 --> <input>:6:9
  |
4 |     hooks:
5 |       - id: trailing-whitespace
6 |       - name: end-of-file-fixer
  |         ^ missing field `id` at line 6, column 9
7 |       - id: check-yaml
8 |       - id: check-added-large-files
  |
```
2026-02-02 20:40:15 +08:00
Jo b0702823df Replace serde-yaml with serde-saphyr (again) (#1520)
serde-saphyr has way better error message, and it is written in safe
Rust.

Previous try: #1087
Previous revert: #1106 and #1112

TODO:
Replace serialize_yaml_scalar with serde-saphyr as well:


https://github.com/j178/prek/blob/0a4be22599076b8c6273940b2760828b442c78f4/crates/prek/src/yaml.rs#L12-L13
2026-02-02 20:19:51 +08:00
Domen Kožar 2a44762ce7 Add cachix/devenv as project using prek (#1531) 2026-02-02 19:09:25 +08:00
Jo 57980aec57 Add CODEOWNERS file (#1532) 2026-02-02 18:28:46 +08:00
Shaan Majid 4f718afe21 ci: tidy up workflows and restore lost bits (#1527) 2026-02-02 15:24:01 +08:00
Shaan Majid 0ec378e3c9 fix(ci): run zizmor on push to master, not main (#1525) 2026-02-02 15:23:52 +08:00
renovate[bot] c78439e5ff Update taiki-e/install-action action to v2.67.10 (#1524) 2026-02-02 03:43:42 +08:00
Les Freire 0a4be22599 Support Julia language (#1519)
resolve #1446

---------

Co-authored-by: Jo <10510431+j178@users.noreply.github.com>
2026-02-01 16:13:55 +08:00
Jo c5c98622ab Improve max cli arguments length calculation (#1518)
Adapted from https://github.com/sharkdp/argmax
2026-02-01 13:22:36 +08:00
Jo 1808e0f629 Add OpenClaw to the list of users (#1517) 2026-02-01 12:15:05 +08:00
Aleksey f10ae08be6 Add PREK_QUIET environment variable support (#1513)
This PR addresses issue #1512 by adding `PREK_QUIET` environment
variable support for controlling quiet output mode (analogous to
`-q`/`-qq` flags).

Key changes include:
- `PREK_QUIET=1` -> quiet mode (like `-q`)
- `PREK_QUIET=2` -> silent mode (like `-qq`)
- Added integration tests and documentation
2026-02-01 09:40:21 +08:00
Robert Muir 711ecf8831 Add apache/lucene to the users of prek (#1514) 2026-02-01 09:35:51 +08:00
renovate[bot] f3a7b8b321 Update GitHub Actions (#1515) 2026-02-01 09:34:28 +08:00
Shaan Majid 4525825ea8 docs: remove todo.md (#1501)
- Remove `todo.md` as remaining items have been addressed or documented
elsewhere.
- Move note to `diff.md` that `pre-commit hazmat` subcommand (v4.5.0) is
not implemented.
2026-01-31 22:34:14 +08:00
Jo bc142a25ff Fix permission for docker attestation (#1511) v0.3.1 2026-01-31 21:13:38 +08:00
Jo 41a26c1c0f Bump version to 0.3.1 (#1510) 2026-01-31 20:56:29 +08:00
Les Freire d12e0be035 Support haskell language (#1484)
resolve #1445

---------

Co-authored-by: Jo <10510431+j178@users.noreply.github.com>
2026-01-31 20:28:42 +08:00
Jo f3d26b65d1 Run each language tests in a separate job (#1508) 2026-01-31 19:49:26 +08:00
An Guoli b1dcb304e9 Skip version_info test if not built in git repository (#1507)
Signed-off-by: qaqland <anguoli@uniontech.com>
2026-01-31 16:59:43 +08:00
Jo 14726d8bad Cap ARG_MAX at 1<<19 for safety (#1506)
Closes #1491
2026-01-31 16:59:24 +08:00
Jo 1000d9bfb5 Add a note about the .pre-commit-config.yaml file name for new users (#1505)
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
2026-01-31 15:24:31 +08:00
Shaan Majid 09f1a99947 docs(installation): miscellaneous cleanup (#1502)
Co-authored-by: Jo <10510431+j178@users.noreply.github.com>
2026-01-31 15:20:04 +08:00
Jo d3425790d1 Show progress bar when running builtin hooks (#1504) 2026-01-31 15:06:36 +08:00
Shaan Majid 7e1a49701c docs: add commands for artifact verification using GitHub Attestations (#1500)
Document how to verify release artifacts and Docker images using `gh
attestation verify`.

Refs: #1494, #1497
2026-01-31 13:34:54 +08:00
Daniel Halmschlager 1baa911576 Don't check Python executable path in health check (#1496) 2026-01-31 10:12:32 +08:00
Shaan Majid 4ddc5159f7 Add GitHub artifact attestations to Docker workflow (#1497)
Adds
[actions/attest-build-provenance](https://github.com/actions/attest-build-provenance)
to the Docker build workflow so consumers can verify images were built
by CI:

```bash
gh attestation verify oci://ghcr.io/j178/prek:latest --repo j178/prek
```

Similar to #1494 which added attestations for release artifacts.

Reference:
[astral-sh/uv#8685](https://github.com/astral-sh/uv/pull/8685)
2026-01-31 01:55:53 +08:00
Jo cc3d76ebb3 Remove some .expect() (#1495) 2026-01-30 13:15:48 +08:00
Shaan Majid 1c77342045 fix(node,bun): include toolchain in PATH during install (#1492)
## Summary

PR #1488 removed symlinks from `bin_dir` but only updated `run()` to
prepend the toolchain directory to PATH. The `install()` functions still
only prepended `bin_dir`, causing `npm install` to fail when no system
node is available in PATH.

## MRE

With `.pre-commit-config.yaml`:
```yaml
repos:
  - repo: https://github.com/pre-commit/mirrors-prettier
    rev: v3.1.0
    hooks:
      - id: prettier
        language_version: "24.13.0"
```

When no system node is in PATH (can be simulated with
`PATH=/usr/bin:/bin`, running:
```bash
prek run --all-files
```

Fails with
```
error: Failed to install hook `prettier`
  caused by: Command `npm install` exited with an error:
env: node: No such file or directory
```

With system node in PATH, `npm install` "works" but uses wrong node
version (system instead of requested).

## Fix

Mirror the `run()` PATH setup in `install()` by including the
toolchain's parent directory:

```rust
let node_bin = node.node().parent().expect("Node binary must have parent");
let new_path = prepend_paths(&[&bin_dir, node_bin])?;
```

Note: Bun fix is for consistency/edge cases (bun is a native binary, not
a shebang script like npm).

---------

Co-authored-by: Jo <10510431+j178@users.noreply.github.com>
2026-01-30 12:06:41 +08:00
Simon Olofsson 8d28063a5d Warn when config file exists but fails to parse (#1487)
## Summary

Previously, `prek install` would silently fall back to default hook
types when the config file existed but contained errors (e.g., invalid
YAML or missing required fields). This made it hard to notice
configuration mistakes.

Now it shows a warning with the specific error:

```
$ prek install
warning: Failed to parse `.pre-commit-config.yaml`: Invalid remote repo: missing field `rev`
prek installed at `.git/hooks/pre-commit`
```

## Test plan

- [x] Added `install_invalid_config_warning` test
- [x] All existing install tests pass

🤖 Generated with [Claude Code](https://claude.ai/code)

---------

Co-authored-by: Claude Opus 4.5 <noreply@anthropic.com>
Co-authored-by: Jo <10510431+j178@users.noreply.github.com>
2026-01-30 11:50:15 +08:00
Shaan Majid dbca90425f Add GitHub artifact attestations to release workflow (#1494)
Closes #1493

Adds
[actions/attest-build-provenance](https://github.com/actions/attest-build-provenance)
to the release workflow so consumers can verify artifacts were built by
CI:

```bash
gh attestation verify <artifact> --repo j178/prek
```

GitHub already generates release attestations that verify file integrity
(checksums), but build provenance additionally proves the artifacts were
produced by the CI workflow rather than uploaded manually.
2026-01-30 11:19:08 +08:00
Jo 7640685371 Do not symlink node/bun binary into env dir (#1488)
Prepend the toolchain directory to PATH instead.
2026-01-29 14:06:24 +08:00
Jo a69f9eb680 Bump rust toolchain to 1.93 (#1486) 2026-01-28 18:02:58 +08:00
Srihari Thyagarajan 09a16286df Include CocoIndex as a project using prek (#1477)
Add [`CocoIndex`](https://github.com/cocoindex-io/cocoindex) to the list
of projects using `prek`.
Relevant [issue](https://github.com/cocoindex-io/cocoindex/issues/1552)
and [PR.](https://github.com/cocoindex-io/cocoindex/pull/1564)
2026-01-28 10:59:07 +08:00
Shaan Majid f0d96ec853 Allow GIT_CONFIG_PARAMETERS for private repository authentication (#1472) 2026-01-28 08:35:52 +08:00
jh8 d9facc079d Update copilot-instructions.md about testing (#1483) 2026-01-27 19:43:03 +08:00
Jo bb8a1b4998 Use hint: consistently (#1482) 2026-01-27 15:18:19 +08:00