File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change 1+ #! /usr/bin/env bash
2+ # PreToolUse hook: block direct edits to generated dictionary data files.
3+ # These files are produced by the dictionary compiler and must not be edited manually.
4+ # Exit code 2 blocks the tool from executing.
5+
6+ set -euo pipefail
7+
8+ command -v jq > /dev/null 2>&1 || exit 0
9+
10+ INPUT=$( cat)
11+ FILE_PATH=$( echo " $INPUT " | jq -r ' .tool_input.file_path // empty' )
12+
13+ if [[ -z " $FILE_PATH " ]]; then
14+ exit 0
15+ fi
16+
17+ # Reject paths with newlines or path traversal
18+ if [[ " $FILE_PATH " =~ $' \n ' ]] || [[ " $FILE_PATH " == * " .." * ]]; then
19+ exit 2
20+ fi
21+
22+ # Block generated data files in Source/Data/ (absolute or relative paths)
23+ case " $FILE_PATH " in
24+ * /Source/Data/data.txt|* /Source/Data/data-plain-bpmf.txt|* /Source/Data/associated-phrases-v2.txt| \
25+ Source/Data/data.txt|Source/Data/data-plain-bpmf.txt|Source/Data/associated-phrases-v2.txt)
26+ echo " Blocked: $FILE_PATH is a generated file. Edit the source and rebuild instead." >&2
27+ exit 2
28+ ;;
29+ esac
Original file line number Diff line number Diff line change 1+ #! /usr/bin/env bash
2+ # PostToolUse hook: auto-format C++/ObjC files with clang-format after edits.
3+ # Reads the tool input JSON from stdin to extract the edited file path.
4+
5+ set -euo pipefail
6+
7+ command -v jq > /dev/null 2>&1 || exit 0
8+
9+ # Read stdin JSON and extract file_path
10+ INPUT=$( cat)
11+ FILE_PATH=$( echo " $INPUT " | jq -r ' .tool_input.file_path // empty' )
12+
13+ if [[ -z " $FILE_PATH " ]]; then
14+ exit 0
15+ fi
16+
17+ # Reject paths with newlines, nulls, or path traversal
18+ if [[ " $FILE_PATH " =~ $' \n ' ]] || [[ " $FILE_PATH " =~ $' \0' ]] || [[ " $FILE_PATH " == * " .." * ]]; then
19+ exit 0
20+ fi
21+
22+ # Only format C++/ObjC source files
23+ case " $FILE_PATH " in
24+ * .cpp|* .h|* .mm|* .m)
25+ if [[ -f " $FILE_PATH " ]]; then
26+ xcrun clang-format -i -- " $FILE_PATH "
27+ fi
28+ ;;
29+ esac
Original file line number Diff line number Diff line change 1+ {
2+ "hooks" : {
3+ "PostToolUse" : [
4+ {
5+ "matcher" : " Edit|Write" ,
6+ "hooks" : [
7+ {
8+ "type" : " command" ,
9+ "command" : " bash .claude/hooks/format-cpp.sh"
10+ }
11+ ]
12+ }
13+ ],
14+ "PreToolUse" : [
15+ {
16+ "matcher" : " Edit|Write" ,
17+ "hooks" : [
18+ {
19+ "type" : " command" ,
20+ "command" : " bash .claude/hooks/block-generated-data.sh"
21+ }
22+ ]
23+ }
24+ ]
25+ }
26+ }
Original file line number Diff line number Diff line change 1+ ---
2+ description : Verify branch and worktree before making edits
3+ user-invocable : false
4+ ---
5+
6+ # Branch Guard
7+
8+ Before editing files, verify:
9+
10+ 1 . ** Current branch** : Run ` git rev-parse --abbrev-ref HEAD ` and confirm it matches the expected branch for the current task.
11+
12+ 2 . ** Worktree isolation** : Run ` git rev-parse --show-toplevel ` and confirm edits target the correct worktree directory.
13+
14+ 3 . ** Clean state** : Run ` git status --porcelain ` and warn if there are uncommitted changes that might conflict.
15+
16+ If any check fails, stop and alert the user before proceeding.
Original file line number Diff line number Diff line change 1+ ---
2+ description : Build and run C++ engine tests
3+ user-invocable : true
4+ ---
5+
6+ # /engine-test
7+
8+ Build and run the full C++ engine unit tests.
9+
10+ ## Steps
11+
12+ 1 . Create the build directory if needed:
13+ ``` bash
14+ mkdir -p Source/Engine/build
15+ ```
16+
17+ 2 . Configure with CMake:
18+ ``` bash
19+ cd Source/Engine/build && cmake -DENABLE_TEST=ON -DCMAKE_EXPORT_COMPILE_COMMANDS=ON ..
20+ ```
21+
22+ 3 . Build:
23+ ``` bash
24+ cd Source/Engine/build && make -j$( sysctl -n hw.ncpu)
25+ ```
26+
27+ 4 . Run tests:
28+ ``` bash
29+ cd Source/Engine/build && ctest --output-on-failure
30+ ```
31+
32+ Report test results. If any tests fail, show the failing test names and output.
Original file line number Diff line number Diff line change @@ -16,4 +16,6 @@ xcuserdata
1616.vscode
1717__pycache__
1818codecov_comment.md
19- DerivedData
19+ DerivedData
20+ compile_commands.json
21+ .cache
You can’t perform that action at this time.
0 commit comments