-
Notifications
You must be signed in to change notification settings - Fork 94
docs(agents): add development guardrails, C++ language server docs, and Claude Code automation #787
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: master
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change | ||||||||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
| @@ -0,0 +1,29 @@ | ||||||||||||||||||||
| #!/usr/bin/env bash | ||||||||||||||||||||
| # PreToolUse hook: block direct edits to generated dictionary data files. | ||||||||||||||||||||
| # These files are produced by the dictionary compiler and must not be edited manually. | ||||||||||||||||||||
| # Exit code 2 blocks the tool from executing. | ||||||||||||||||||||
|
|
||||||||||||||||||||
| set -euo pipefail | ||||||||||||||||||||
|
|
||||||||||||||||||||
| command -v jq >/dev/null 2>&1 || exit 0 | ||||||||||||||||||||
|
|
||||||||||||||||||||
| INPUT=$(cat) | ||||||||||||||||||||
| FILE_PATH=$(echo "$INPUT" | jq -r '.tool_input.file_path // empty') | ||||||||||||||||||||
|
|
||||||||||||||||||||
| if [[ -z "$FILE_PATH" ]]; then | ||||||||||||||||||||
| exit 0 | ||||||||||||||||||||
| fi | ||||||||||||||||||||
|
|
||||||||||||||||||||
| # Reject paths with newlines or path traversal | ||||||||||||||||||||
| if [[ "$FILE_PATH" =~ $'\n' ]] || [[ "$FILE_PATH" == *".."* ]]; then | ||||||||||||||||||||
| exit 2 | ||||||||||||||||||||
| fi | ||||||||||||||||||||
|
tianjianjiang marked this conversation as resolved.
|
||||||||||||||||||||
|
|
||||||||||||||||||||
| # Block generated data files in Source/Data/ (absolute or relative paths) | ||||||||||||||||||||
| case "$FILE_PATH" in | ||||||||||||||||||||
| */Source/Data/data.txt|*/Source/Data/data-plain-bpmf.txt|*/Source/Data/associated-phrases-v2.txt| \ | ||||||||||||||||||||
| Source/Data/data.txt|Source/Data/data-plain-bpmf.txt|Source/Data/associated-phrases-v2.txt) | ||||||||||||||||||||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Bug: line continuation introduces leading whitespace into In bash,
Suggested change
Each alternative must start the continuation line without leading whitespace to avoid embedding spaces into the pattern. |
||||||||||||||||||||
| echo "Blocked: $FILE_PATH is a generated file. Edit the source and rebuild instead." >&2 | ||||||||||||||||||||
| exit 2 | ||||||||||||||||||||
| ;; | ||||||||||||||||||||
|
tianjianjiang marked this conversation as resolved.
|
||||||||||||||||||||
| esac | ||||||||||||||||||||
|
tianjianjiang marked this conversation as resolved.
|
||||||||||||||||||||
| Original file line number | Diff line number | Diff line change | ||||||||
|---|---|---|---|---|---|---|---|---|---|---|
| @@ -0,0 +1,29 @@ | ||||||||||
| #!/usr/bin/env bash | ||||||||||
| # PostToolUse hook: auto-format C++/ObjC files with clang-format after edits. | ||||||||||
| # Reads the tool input JSON from stdin to extract the edited file path. | ||||||||||
|
|
||||||||||
| set -euo pipefail | ||||||||||
|
|
||||||||||
|
tianjianjiang marked this conversation as resolved.
|
||||||||||
| command -v jq >/dev/null 2>&1 || exit 0 | ||||||||||
|
|
||||||||||
| # Read stdin JSON and extract file_path | ||||||||||
| INPUT=$(cat) | ||||||||||
|
tianjianjiang marked this conversation as resolved.
|
||||||||||
| FILE_PATH=$(echo "$INPUT" | jq -r '.tool_input.file_path // empty') | ||||||||||
|
|
||||||||||
| if [[ -z "$FILE_PATH" ]]; then | ||||||||||
| exit 0 | ||||||||||
| fi | ||||||||||
|
|
||||||||||
| # Reject paths with newlines, nulls, or path traversal | ||||||||||
| if [[ "$FILE_PATH" =~ $'\n' ]] || [[ "$FILE_PATH" =~ $'\0' ]] || [[ "$FILE_PATH" == *".."* ]]; then | ||||||||||
|
tianjianjiang marked this conversation as resolved.
|
||||||||||
| exit 0 | ||||||||||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Dead check: bash variables cannot contain null bytes.
Suggested change
Remove the null-byte check (it mirrors the guard already used in |
||||||||||
| fi | ||||||||||
|
|
||||||||||
| # Only format C++/ObjC source files | ||||||||||
| case "$FILE_PATH" in | ||||||||||
| *.cpp|*.h|*.mm|*.m) | ||||||||||
| if [[ -f "$FILE_PATH" ]]; then | ||||||||||
| xcrun clang-format -i -- "$FILE_PATH" | ||||||||||
|
tianjianjiang marked this conversation as resolved.
|
||||||||||
| fi | ||||||||||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
With
Suggested change
|
||||||||||
| ;; | ||||||||||
| esac | ||||||||||
|
tianjianjiang marked this conversation as resolved.
tianjianjiang marked this conversation as resolved.
|
||||||||||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,26 @@ | ||
| { | ||
| "hooks": { | ||
| "PostToolUse": [ | ||
| { | ||
| "matcher": "Edit|Write", | ||
| "hooks": [ | ||
| { | ||
|
tianjianjiang marked this conversation as resolved.
|
||
| "type": "command", | ||
| "command": "bash .claude/hooks/format-cpp.sh" | ||
| } | ||
| ] | ||
| } | ||
| ], | ||
| "PreToolUse": [ | ||
| { | ||
| "matcher": "Edit|Write", | ||
| "hooks": [ | ||
| { | ||
| "type": "command", | ||
| "command": "bash .claude/hooks/block-generated-data.sh" | ||
| } | ||
| ] | ||
| } | ||
| ] | ||
| } | ||
| } | ||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,16 @@ | ||
| --- | ||
| description: Verify branch and worktree before making edits | ||
| user-invocable: false | ||
| --- | ||
|
|
||
| # Branch Guard | ||
|
|
||
| Before editing files, verify: | ||
|
|
||
| 1. **Current branch**: Run `git rev-parse --abbrev-ref HEAD` and confirm it matches the expected branch for the current task. | ||
|
|
||
| 2. **Worktree isolation**: Run `git rev-parse --show-toplevel` and confirm edits target the correct worktree directory. | ||
|
|
||
| 3. **Clean state**: Run `git status --porcelain` and warn if there are uncommitted changes that might conflict. | ||
|
|
||
| If any check fails, stop and alert the user before proceeding. |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,32 @@ | ||
| --- | ||
| description: Build and run C++ engine tests | ||
| user-invocable: true | ||
| --- | ||
|
|
||
| # /engine-test | ||
|
|
||
| Build and run the full C++ engine unit tests. | ||
|
|
||
| ## Steps | ||
|
|
||
| 1. Create the build directory if needed: | ||
| ```bash | ||
| mkdir -p Source/Engine/build | ||
| ``` | ||
|
|
||
| 2. Configure with CMake: | ||
| ```bash | ||
| cd Source/Engine/build && cmake -DENABLE_TEST=ON -DCMAKE_EXPORT_COMPILE_COMMANDS=ON .. | ||
| ``` | ||
|
|
||
| 3. Build: | ||
| ```bash | ||
| cd Source/Engine/build && make -j$(sysctl -n hw.ncpu) | ||
| ``` | ||
|
|
||
| 4. Run tests: | ||
| ```bash | ||
| cd Source/Engine/build && ctest --output-on-failure | ||
| ``` | ||
|
|
||
| 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 | |
| .vscode | ||
| __pycache__ | ||
| codecov_comment.md | ||
| DerivedData | ||
| DerivedData | ||
| compile_commands.json | ||
| .cache | ||
Uh oh!
There was an error while loading. Please reload this page.