@@ -16,12 +16,79 @@ Athena is a gRPC-based image classification service designed for CSAM (Child Sex
1616
1717# Contributing
1818
19+ ## Code Quality and Pre-commit Hooks
20+
21+ This project uses pre-commit hooks to ensure code quality and consistency. The hooks run linting, formatting, and type checking before each commit.
22+
23+ ### Setting up Pre-commit Hooks
24+
25+ 1 . ** Install pre-commit** (if not already installed):
26+ ``` sh
27+ uvx pre-commit --help
28+ ```
29+ Or install globally:
30+ ``` sh
31+ uv tool install pre-commit
32+ ```
33+
34+ 2 . ** Install the hooks** :
35+ ``` sh
36+ uvx pre-commit install
37+ ```
38+
39+ 3 . ** Run all quality checks manually** :
40+ ``` sh
41+ npm run lint:all
42+ ```
43+
44+ ### What the Pre-commit Hooks Check
45+
46+ - ** ESLint** : Code quality and style issues
47+ - ** Prettier** : Code formatting consistency
48+ - ** TypeScript** : Type checking and compilation
49+ - ** File checks** : Trailing whitespace, file endings, large files, etc.
50+ - ** Submodule status** : Ensures submodules are properly tracked
51+
52+ ### Manual Quality Checks
53+
54+ You can run individual checks manually:
55+
56+ ``` sh
57+ # Run ESLint
58+ npm run lint
59+
60+ # Check Prettier formatting
61+ npm run prettier:check
62+
63+ # Fix Prettier formatting
64+ npm run prettier
65+
66+ # TypeScript type checking
67+ npx tsc --noEmit
68+
69+ # Run all checks at once
70+ npm run lint:all
71+ ```
72+
1973## Updating the Protobuf definitions
2074
21- Protobufs are stored in the [ @crispthinking/athena-protobuffs ] ( https://github.com/crispthinking/athena-protobufs ) repository.
75+ Protobufs are stored as a git submodule from the [ @crispthinking/athena-protobufs ] ( https://github.com/crispthinking/athena-protobufs.git ) repository.
2276
23- To update the protobuf definitions for client generation, run:
24- ` git subtree pull --prefix=athena-protobufs https://github.com/crispthinking/athena-protobufs.git <sha> --squash `
77+ To update the protobuf definitions for client generation:
78+
79+ 1 . ** Update the submodule to the latest version:**
80+ ``` sh
81+ git submodule update --remote athena-protobufs
82+ ```
83+
84+ 2 . ** Or update to a specific commit:**
85+ ``` sh
86+ cd athena-protobufs
87+ git checkout < commit-sha>
88+ cd ..
89+ git add athena-protobufs
90+ git commit -m " Update protobuf definitions to <commit-sha>"
91+ ```
2592
2693## Regenerating the TypeScript gRPC Client
2794
@@ -36,6 +103,11 @@ This project uses [`@protobuf-ts/plugin`](https://github.com/timostamm/protobuf-
36103 ```
37104
381052 . ** Run the following command to regenerate the client and types:**
106+ ```sh
107+ npm run codegen
108+ ```
109+
110+ Or manually with:
39111 ```sh
40112 npx protoc \
41113 --plugin=protoc-gen-ts=./node_modules/.bin/protoc-gen-ts \
@@ -49,9 +121,15 @@ This project uses [`@protobuf-ts/plugin`](https://github.com/timostamm/protobuf-
49121 - The main client will be in `src/athena/athena.grpc-client.ts`.
50122 - Message types and enums are in `src/athena/athena.ts`.
51123
124+ 3 . ** Format the generated code:**
125+ ```sh
126+ npm run prettier
127+ ```
128+
52129### Notes
53- - If you add or change proto files, rerun the above command to keep the TypeScript client in sync.
130+ - If you update proto files in the submodule , rerun ` npm run codegen ` to keep the TypeScript client in sync.
54131- If you see TypeScript errors about missing modules, ensure your ` tsconfig.json ` includes the ` src/athena ` directory and restart your IDE/tsserver.
132+ - The generated files are automatically formatted by the pre-commit hooks, but you can run ` npm run prettier ` manually if needed.
55133
56134---
57135
@@ -65,4 +143,4 @@ curl -LsSf https://astral.sh/uv/install.sh | sh
65143uv sync
66144cd docs
67145make html
68- The built documentation will be available in docs/build/html/index.html.
146+ The built documentation will be available in docs/build/html/index.html.
0 commit comments