Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions .agents/skills
17 changes: 17 additions & 0 deletions .codex/hooks.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
{
"hooks": {
"PostToolUse": [
{
"matcher": "Edit|Write",
"hooks": [
{
"type": "command",
"command": "\"$(git rev-parse --show-toplevel)/Scripts/codex-hooks/swift-format-and-lint.sh\"",
"timeout": 60,
"statusMessage": "Formatting and linting Swift..."
}
]
}
]
}
}
34 changes: 34 additions & 0 deletions Scripts/codex-hooks/swift-format-and-lint.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
#!/bin/sh
# Codex PostToolUse hook: format and lint Swift files edited through apply_patch.
# Codex provides the applied patch in tool_input.command, while Claude Code provides
# the edited path directly. Support both payloads so the hook remains easy to reuse.

files=$(jq -r '
.tool_input.file_path? // empty,
((.tool_input.command? // .tool_input.patch? // "") | split("\n")[] |
if startswith("*** Update File: ") then ltrimstr("*** Update File: ")
elif startswith("*** Add File: ") then ltrimstr("*** Add File: ")
else empty
end)
' | awk '/\.swift$/ { print }' | sort -u)

[ -n "$files" ] || exit 0

for file in $files; do
[ -f "$file" ] || continue
xcrun swift format --in-place "$file" 2>/dev/null || true
done

command -v rake >/dev/null 2>&1 || exit 0

status=0
for file in $files; do
[ -f "$file" ] || continue
out=$(rake -s "lint[$file]" 2>&1)
if [ -n "$out" ]; then
echo "$out" >&2
status=2
fi
done

exit "$status"