Skip to content

Commit 2e4430a

Browse files
authored
feat(tooling): add pre-commit hooks support (#609)
* feat(tooling): add pre-commit hooks support
1 parent 7ea31ad commit 2e4430a

File tree

6 files changed

+73
-1
lines changed

6 files changed

+73
-1
lines changed

.github/workflows/maven.yaml

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -57,6 +57,25 @@ jobs:
5757
env:
5858
SKILL_CHECK_NO_BANNER: 1
5959

60+
pre-commit:
61+
name: Pre-commit
62+
runs-on: ubuntu-latest
63+
steps:
64+
- uses: actions/checkout@v6
65+
with:
66+
submodules: true
67+
- uses: actions/setup-python@v6
68+
with:
69+
python-version: "3.x"
70+
- name: Install pre-commit
71+
run: pip install pre-commit
72+
- name: Run pre-commit (all files)
73+
run: pre-commit run --all-files
74+
- name: Validate HEAD commit message
75+
run: |
76+
git log -1 --pretty=%B > /tmp/commit-msg.txt
77+
pre-commit run conventional-pre-commit --hook-stage commit-msg --commit-msg-filename /tmp/commit-msg.txt
78+
6079
examples:
6180
name: Build Examples
6281
runs-on: ubuntu-latest

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,3 +8,4 @@ target/
88
dependency-reduced-pom.xml
99
docs-local/
1010
.quarkus/
11+
.venv-precommit/

.pre-commit-config.yaml

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
# https://pre-commit.com/
2+
# Install: pip install pre-commit && pre-commit install --install-hooks
3+
# Commit messages must match AGENTS.md (Conventional Commits + required scope).
4+
default_install_hook_types:
5+
- pre-commit
6+
- commit-msg
7+
8+
repos:
9+
- repo: https://github.com/pre-commit/pre-commit-hooks
10+
rev: v6.0.0
11+
hooks:
12+
- id: check-yaml
13+
14+
- repo: https://github.com/compilerla/conventional-pre-commit
15+
rev: v4.4.0
16+
hooks:
17+
- id: conventional-pre-commit
18+
stages: [commit-msg]
19+
args:
20+
- --force-scope
21+
- feat
22+
- fix
23+
- docs
24+
- style
25+
- refactor
26+
- test
27+
- chore

AGENTS.md

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -66,6 +66,24 @@ npx skill-check skills
6666
- `fix(generator): resolve template parsing issue`
6767
- `docs(readme): update installation instructions`
6868

69+
### Pre-commit hooks (recommended)
70+
71+
This repository includes [pre-commit](https://pre-commit.com/) configuration at [`.pre-commit-config.yaml`](.pre-commit-config.yaml): YAML checks and a **commit-msg** hook that enforces the [Conventional Commits](https://www.conventionalcommits.org/en/v1.0.0/) rules above (including a required **scope**).
72+
73+
**Setup (once per clone):**
74+
75+
```bash
76+
pip install pre-commit # or: brew install pre-commit
77+
pre-commit install --install-hooks
78+
```
79+
80+
The install registers both the default `pre-commit` stage and `commit-msg` hooks. To validate the latest commit message manually:
81+
82+
```bash
83+
git log -1 --pretty=%B > /tmp/msg.txt
84+
pre-commit run conventional-pre-commit --hook-stage commit-msg --commit-msg-filename /tmp/msg.txt
85+
```
86+
6987
## Boundaries
7088

7189
-**Always do:** Edit XML in `system-prompts-generator/src/main/resources/` to change rules, run `./mvnw clean verify` before promoting changes. When edit XML, follow PML Schema: [https://jabrena.github.io/pml/schemas/0.7.0/pml.xsd](https://jabrena.github.io/pml/schemas/0.7.0/pml.xsd).

CONTRIBUTING.md

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,12 @@
11
# Contributing
22

3+
## Conventions
4+
5+
Read [AGENTS.md](./AGENTS.md) for the full contributor guide (tech stack, boundaries, and commands).
6+
7+
- **Git:** use [Conventional Commits](https://www.conventionalcommits.org/) in the form `type(scope): description`, with types such as `feat`, `fix`, `docs`, `style`, `refactor`, `test`, and `chore` (see AGENTS.md).
8+
- **Pre-commit (recommended):** this repo includes [pre-commit](https://pre-commit.com/) in [`.pre-commit-config.yaml`](.pre-commit-config.yaml) (YAML checks and a commit-msg hook aligned with the rules above). Install once per clone: `pip install pre-commit` or `brew install pre-commit`, then `pre-commit install --install-hooks`. Details and manual checks are in AGENTS.md under **Pre-commit hooks**.
9+
310
## Generator
411

512
The entire set of cursor rules is autogenerated by XML files in the project `system-prompts-generator`.

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -74,7 +74,7 @@ Models are able to generate code, but they cannot run code with your local data.
7474

7575
## Contribute
7676

77-
If you have great ideas, [read the following document](./CONTRIBUTING.md) to contribute.
77+
See [CONTRIBUTING.md](./CONTRIBUTING.md) for conventions, generator workflows, tests, and how to open a pull request.
7878

7979
## Examples
8080

0 commit comments

Comments
 (0)