Skip to content

Commit cdb675f

Browse files
feat: add Copilot hooks for OSF schedule context and auto-refresh
- SessionStart: prints upcoming streams table at session open - PostToolUse: re-runs update_schedule.py when schedule script or issue templates are edited Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
1 parent 0682021 commit cdb675f

3 files changed

Lines changed: 69 additions & 0 deletions

File tree

.github/hooks/osf-schedule.json

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
{
2+
"hooks": {
3+
"SessionStart": [
4+
{
5+
"type": "command",
6+
"command": "bash .github/hooks/scripts/show-schedule.sh",
7+
"cwd": ".",
8+
"timeout": 10
9+
}
10+
],
11+
"PostToolUse": [
12+
{
13+
"type": "command",
14+
"command": "bash .github/hooks/scripts/on-tool-use.sh",
15+
"cwd": ".",
16+
"timeout": 60
17+
}
18+
]
19+
}
20+
}
Lines changed: 42 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,42 @@
1+
#!/usr/bin/env bash
2+
# PostToolUse hook: re-run the schedule script when relevant files are edited
3+
set -euo pipefail
4+
5+
# Read hook payload from stdin
6+
PAYLOAD=$(cat)
7+
8+
# Extract the file path touched (works for editFiles, createFile, apply_patch, str_replace_editor)
9+
TOUCHED=$(echo "$PAYLOAD" | python3 -c "
10+
import json, sys
11+
try:
12+
p = json.load(sys.stdin)
13+
inp = p.get('input', {})
14+
# Different tools use different field names
15+
path = (
16+
inp.get('filePath') or
17+
inp.get('path') or
18+
inp.get('target_file') or
19+
''
20+
)
21+
print(path)
22+
except Exception:
23+
print('')
24+
" 2>/dev/null || true)
25+
26+
# Only re-run the schedule script if a relevant file was edited
27+
case "$TOUCHED" in
28+
.github/scripts/update_schedule.py|\
29+
.github/ISSUE_TEMPLATE/*.yml|\
30+
README.md)
31+
echo "[osf-hook] Detected edit to '$TOUCHED' — refreshing schedule table..."
32+
if [ -z "${GITHUB_TOKEN:-}" ]; then
33+
echo "[osf-hook] GITHUB_TOKEN not set, skipping schedule refresh."
34+
exit 0
35+
fi
36+
python3 .github/scripts/update_schedule.py
37+
echo "[osf-hook] Schedule table updated."
38+
;;
39+
*)
40+
exit 0
41+
;;
42+
esac
Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
#!/usr/bin/env bash
2+
# SessionStart hook: print the current upcoming streams so Copilot has context
3+
set -euo pipefail
4+
5+
echo "=== Open Source Friday – Upcoming Streams ==="
6+
awk '/<!-- SCHEDULE_START -->/,/<!-- SCHEDULE_END -->/' README.md | grep -v "SCHEDULE_" || echo "(No schedule table found)"
7+
echo ""

0 commit comments

Comments
 (0)