-
Notifications
You must be signed in to change notification settings - Fork 4
158 lines (136 loc) · 5.35 KB
/
check-skills.yml
File metadata and controls
158 lines (136 loc) · 5.35 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
# check-skills.yml — Drop this into your library repo's .github/workflows/
#
# Checks for stale intent skills after a release and opens a review PR
# if any skills need attention. The PR body includes a prompt you can
# paste into Claude Code, Cursor, or any coding agent to update them.
#
# Triggers: new release published, or manual workflow_dispatch.
#
# Template variables (replaced by `intent setup`):
# proofkit
name: Check Skills
on:
repository_dispatch:
types: [skill-check]
release:
types: [published]
workflow_dispatch: {}
permissions:
contents: write
pull-requests: write
jobs:
check:
name: Check for stale skills
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v4
with:
fetch-depth: 0
- name: Setup Node
uses: actions/setup-node@v4
with:
node-version: 20
- name: Install intent
run: npm install -g @tanstack/intent
- name: Check staleness
id: stale
run: |
# Monorepo workaround: intent stale doesn't find packages from repo root
# Run in each package directory that has skills/
ALL_OUTPUT="[]"
for dir in packages/*/skills; do
PKG_DIR=$(dirname "$dir")
echo "Checking $PKG_DIR..."
PKG_OUTPUT=$(cd "$PKG_DIR" && intent stale --json 2>&1) || true
ALL_OUTPUT=$(echo "$ALL_OUTPUT" "$PKG_OUTPUT" | node -e "
const chunks = require('fs').readFileSync('/dev/stdin','utf8').trim().split('\n');
const merged = chunks.reduce((acc, c) => { try { return acc.concat(JSON.parse(c)); } catch { return acc; } }, []);
console.log(JSON.stringify(merged));
")
done
echo "$ALL_OUTPUT"
OUTPUT="$ALL_OUTPUT"
# Check if any skills need review
NEEDS_REVIEW=$(echo "$OUTPUT" | node -e "
const input = require('fs').readFileSync('/dev/stdin','utf8');
try {
const reports = JSON.parse(input);
const stale = reports.flatMap(r =>
r.skills.filter(s => s.needsReview).map(s => ({ library: r.library, skill: s.name, reasons: s.reasons }))
);
if (stale.length > 0) {
console.log(JSON.stringify(stale));
}
} catch {}
")
if [ -z "$NEEDS_REVIEW" ]; then
echo "has_stale=false" >> "$GITHUB_OUTPUT"
else
echo "has_stale=true" >> "$GITHUB_OUTPUT"
# Escape for multiline GH output
EOF=$(dd if=/dev/urandom bs=15 count=1 status=none | base64)
echo "stale_json<<$EOF" >> "$GITHUB_OUTPUT"
echo "$NEEDS_REVIEW" >> "$GITHUB_OUTPUT"
echo "$EOF" >> "$GITHUB_OUTPUT"
fi
- name: Build summary
if: steps.stale.outputs.has_stale == 'true'
id: summary
run: |
node -e "
const stale = JSON.parse(process.env.STALE_JSON);
const lines = stale.map(s =>
'- **' + s.skill + '** (' + s.library + '): ' + s.reasons.join(', ')
);
const summary = lines.join('\n');
const prompt = [
'Review and update the following stale intent skills for proofkit:',
'',
...stale.map(s => '- ' + s.skill + ': ' + s.reasons.join(', ')),
'',
'For each stale skill:',
'1. Read the current SKILL.md file',
'2. Check what changed in the library since the skill was last updated',
'3. Update the skill content to reflect current APIs and behavior',
'4. Run \`npx @tanstack/intent validate\` to verify the updated skill',
].join('\n');
// Write outputs
const fs = require('fs');
const env = fs.readFileSync(process.env.GITHUB_OUTPUT, 'utf8');
const eof = require('crypto').randomBytes(15).toString('base64');
fs.appendFileSync(process.env.GITHUB_OUTPUT,
'summary<<' + eof + '\n' + summary + '\n' + eof + '\n' +
'prompt<<' + eof + '\n' + prompt + '\n' + eof + '\n'
);
"
env:
STALE_JSON: ${{ steps.stale.outputs.stale_json }}
- name: Open review PR
if: steps.stale.outputs.has_stale == 'true'
env:
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
run: |
VERSION="${{ github.event.release.tag_name || 'manual' }}"
BRANCH="skills/review-${VERSION}"
git config user.name "github-actions[bot]"
git config user.email "41898282+github-actions[bot]@users.noreply.github.com"
git checkout -b "$BRANCH"
git commit --allow-empty -m "chore: review stale skills for ${VERSION}"
git push origin "$BRANCH"
gh pr create \
--title "Review stale skills (${VERSION})" \
--body "$(cat <<'PREOF'
## Stale Skills Detected
The following skills may need updates after the latest release:
${{ steps.summary.outputs.summary }}
---
### Update Prompt
Paste this into your coding agent (Claude Code, Cursor, etc.):
~~~
${{ steps.summary.outputs.prompt }}
~~~
PREOF
)" \
--head "$BRANCH" \
--base main