Skip to content

Commit ea78f99

Browse files
update intent workflow (#7243)
1 parent 3a59b72 commit ea78f99

1 file changed

Lines changed: 201 additions & 122 deletions

File tree

‎.github/workflows/check-skills.yml‎

Lines changed: 201 additions & 122 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,14 @@
11
# check-skills.yml — Drop this into your library repo's .github/workflows/
22
#
3-
# Checks for stale intent skills after a release and opens a review PR
4-
# if any skills need attention. The PR body includes a prompt you can
5-
# paste into Claude Code, Cursor, or any coding agent to update them.
3+
# Checks intent skills after a release and opens or updates one review PR when
4+
# existing skills, artifact coverage, or workspace package coverage need review.
65
#
76
# Triggers: new release published, or manual workflow_dispatch.
87
#
9-
# Template variables (replaced by `intent setup`):
10-
# @tanstack/react-router — e.g. @tanstack/query
8+
# intent-workflow-version: 2
119
#
12-
# Adapted for TanStack Router monorepo: loops over all packages with skills.
10+
# Template variables (replaced by `intent setup`):
11+
# @tanstack/router — e.g. @tanstack/query or my-workspace workspace
1312

1413
name: Check Skills
1514

@@ -24,7 +23,7 @@ permissions:
2423

2524
jobs:
2625
check:
27-
name: Check for stale skills
26+
name: Check intent skill coverage
2827
runs-on: ubuntu-latest
2928
steps:
3029
- name: Checkout
@@ -37,136 +36,216 @@ jobs:
3736
with:
3837
node-version: 20
3938

40-
- name: Install intent CLI
39+
- name: Install intent
4140
run: npm install -g @tanstack/intent
4241

43-
- name: Install dependencies
44-
run: npm install --ignore-scripts
45-
env:
46-
npm_config_legacy_peer_deps: 'true'
47-
48-
- name: Check staleness
42+
- name: Check skills
4943
id: stale
5044
run: |
51-
# Monorepo: collect stale reports from all packages with skills
52-
ALL_OUTPUT="["
53-
FIRST=true
54-
for dir in packages/*/; do
55-
if [ -d "$dir/skills" ]; then
56-
PKG_OUTPUT=$(cd "$dir" && npx @tanstack/intent stale --json 2>/dev/null) || true
57-
if [ -n "$PKG_OUTPUT" ] && [ "$PKG_OUTPUT" != "[]" ] && [ "$PKG_OUTPUT" != "No intent-enabled packages found." ]; then
58-
if [ "$FIRST" = true ]; then
59-
FIRST=false
60-
else
61-
ALL_OUTPUT="${ALL_OUTPUT},"
62-
fi
63-
# Strip outer brackets and append entries
64-
ENTRIES=$(echo "$PKG_OUTPUT" | node -e "
65-
const input = require('fs').readFileSync('/dev/stdin','utf8').trim();
66-
try { const arr = JSON.parse(input); process.stdout.write(JSON.stringify(arr).slice(1, -1)); } catch {}
67-
")
68-
ALL_OUTPUT="${ALL_OUTPUT}${ENTRIES}"
69-
fi
70-
fi
71-
done
72-
ALL_OUTPUT="${ALL_OUTPUT}]"
73-
74-
echo "$ALL_OUTPUT"
75-
76-
# Check if any skills need review
77-
NEEDS_REVIEW=$(echo "$ALL_OUTPUT" | node -e "
78-
const input = require('fs').readFileSync('/dev/stdin','utf8');
79-
try {
80-
const reports = JSON.parse(input);
81-
const stale = reports.flatMap(r =>
82-
r.skills.filter(s => s.needsReview).map(s => ({ library: r.library, skill: s.name, reasons: s.reasons }))
83-
);
84-
if (stale.length > 0) {
85-
console.log(JSON.stringify(stale));
86-
}
87-
} catch {}
88-
")
89-
90-
if [ -z "$NEEDS_REVIEW" ]; then
91-
echo "has_stale=false" >> "$GITHUB_OUTPUT"
45+
set +e
46+
intent stale --json > stale.json
47+
STATUS=$?
48+
set -e
49+
50+
cat stale.json
51+
52+
if [ "$STATUS" -ne 0 ]; then
53+
echo "has_review=true" >> "$GITHUB_OUTPUT"
54+
echo "check_failed=true" >> "$GITHUB_OUTPUT"
55+
cat > review-items.json <<'JSON'
56+
[
57+
{
58+
"type": "stale-check-failed",
59+
"library": "@tanstack/router",
60+
"subject": "intent stale --json",
61+
"reasons": ["The stale check command failed. Review the workflow logs before updating skills."]
62+
}
63+
]
64+
JSON
9265
else
93-
echo "has_stale=true" >> "$GITHUB_OUTPUT"
94-
# Escape for multiline GH output
95-
EOF=$(dd if=/dev/urandom bs=15 count=1 status=none | base64)
96-
echo "stale_json<<$EOF" >> "$GITHUB_OUTPUT"
97-
echo "$NEEDS_REVIEW" >> "$GITHUB_OUTPUT"
98-
echo "$EOF" >> "$GITHUB_OUTPUT"
66+
node <<'NODE'
67+
const fs = require('fs')
68+
const reports = JSON.parse(fs.readFileSync('stale.json', 'utf8'))
69+
const items = []
70+
71+
for (const report of reports) {
72+
for (const skill of report.skills ?? []) {
73+
if (!skill?.needsReview) continue
74+
items.push({
75+
type: 'stale-skill',
76+
library: report.library,
77+
subject: skill.name,
78+
reasons: skill.reasons ?? [],
79+
})
80+
}
81+
82+
for (const signal of report.signals ?? []) {
83+
if (signal?.needsReview === false) continue
84+
items.push({
85+
type: signal?.type ?? 'review-signal',
86+
library: signal?.library ?? report.library,
87+
subject:
88+
signal?.packageName ??
89+
signal?.packageRoot ??
90+
signal?.skill ??
91+
signal?.artifactPath ??
92+
signal?.subject ??
93+
report.library,
94+
reasons: signal?.reasons ?? [],
95+
artifactPath: signal?.artifactPath,
96+
packageName: signal?.packageName,
97+
packageRoot: signal?.packageRoot,
98+
skill: signal?.skill,
99+
})
100+
}
101+
}
102+
103+
fs.writeFileSync('review-items.json', JSON.stringify(items, null, 2) + '\n')
104+
fs.appendFileSync(
105+
process.env.GITHUB_OUTPUT,
106+
`has_review=${items.length > 0 ? 'true' : 'false'}\n`,
107+
)
108+
NODE
99109
fi
100110
101-
- name: Build summary
102-
if: steps.stale.outputs.has_stale == 'true'
103-
id: summary
104-
run: |
105-
node -e "
106-
const stale = JSON.parse(process.env.STALE_JSON);
107-
const lines = stale.map(s =>
108-
'- **' + s.skill + '** (' + s.library + '): ' + s.reasons.join(', ')
109-
);
110-
const summary = lines.join('\n');
111-
112-
const prompt = [
113-
'Review and update the following stale intent skills for TanStack Router:',
114-
'',
115-
...stale.map(s => '- ' + s.skill + ': ' + s.reasons.join(', ')),
116-
'',
117-
'For each stale skill:',
118-
'1. Read the current SKILL.md file',
119-
'2. Check what changed in the library since the skill was last updated',
120-
'3. Update the skill content to reflect current APIs and behavior',
121-
'4. Run \`npx @tanstack/intent validate\` to verify the updated skill',
122-
].join('\n');
123-
124-
// Write outputs
125-
const fs = require('fs');
126-
const env = fs.readFileSync(process.env.GITHUB_OUTPUT, 'utf8');
127-
const eof = require('crypto').randomBytes(15).toString('base64');
128-
fs.appendFileSync(process.env.GITHUB_OUTPUT,
129-
'summary<<' + eof + '\n' + summary + '\n' + eof + '\n' +
130-
'prompt<<' + eof + '\n' + prompt + '\n' + eof + '\n'
131-
);
132-
"
133-
env:
134-
STALE_JSON: ${{ steps.stale.outputs.stale_json }}
111+
{
112+
echo "review_items<<EOF"
113+
cat review-items.json
114+
echo "EOF"
115+
} >> "$GITHUB_OUTPUT"
135116
136-
- name: Open review PR
137-
if: steps.stale.outputs.has_stale == 'true'
117+
- name: Write clean summary
118+
if: steps.stale.outputs.has_review == 'false'
119+
run: |
120+
{
121+
echo "### Intent skill review"
122+
echo ""
123+
echo "No stale skills or coverage gaps found."
124+
} >> "$GITHUB_STEP_SUMMARY"
125+
126+
- name: Build review PR body
127+
if: steps.stale.outputs.has_review == 'true'
128+
run: |
129+
node <<'NODE'
130+
const fs = require('fs')
131+
const items = JSON.parse(fs.readFileSync('review-items.json', 'utf8'))
132+
const grouped = new Map()
133+
134+
for (const item of items) {
135+
grouped.set(item.type, (grouped.get(item.type) ?? 0) + 1)
136+
}
137+
138+
const signalRows = [...grouped.entries()]
139+
.sort(([a], [b]) => a.localeCompare(b))
140+
.map(([type, count]) => `| \`${type}\` | ${count} |`)
141+
142+
const itemRows = items.map((item) => {
143+
const subject = item.subject ? `\`${item.subject}\`` : '-'
144+
const reasons = item.reasons?.length ? item.reasons.join('; ') : '-'
145+
return `| \`${item.type}\` | ${subject} | \`${item.library}\` | ${reasons} |`
146+
})
147+
148+
const prompt = [
149+
'You are helping maintain Intent skills for this repository.',
150+
'',
151+
'Goal:',
152+
'Resolve the Intent skill review signals below while preserving the existing scope, taxonomy, and maintainer-reviewed artifacts.',
153+
'',
154+
'Review signals:',
155+
JSON.stringify(items, null, 2),
156+
'',
157+
'Required workflow:',
158+
'1. Read the existing `_artifacts/*domain_map.yaml`, `_artifacts/*skill_tree.yaml`, and generated `skills/**/SKILL.md` files.',
159+
'2. Read each flagged package package.json, public exports, README/docs if present, and source entry points.',
160+
'3. Compare flagged packages against the existing domains, skills, tasks, packages, covers, sources, tensions, and cross-references in the artifacts.',
161+
'4. For each signal, decide whether it means existing skill coverage, a missing generated skill, a new skill candidate, out-of-scope coverage, or deferred work.',
162+
'',
163+
'Maintainer questions:',
164+
'Before editing skills or artifacts, ask the maintainer:',
165+
'1. For each flagged package, is this package user-facing enough to need agent guidance?',
166+
'2. If yes, should it extend an existing skill or become a new skill?',
167+
'3. If it extends an existing skill, which current skill should own it?',
168+
'4. If it is out of scope, what short reason should be recorded in artifact coverage ignores?',
169+
'5. Are any of these packages experimental or unstable enough to exclude for now?',
170+
'',
171+
'Decision rules:',
172+
'- Do not auto-generate skills.',
173+
'- Do not create broad new skill areas without maintainer confirmation.',
174+
'- Prefer adding package coverage to an existing skill when the package is an implementation variant of an existing domain.',
175+
'- Create a new skill only when the package introduces a distinct developer task or failure mode.',
176+
'- Preserve current naming, path, and package layout conventions.',
177+
'- Keep generated skills under the package-local `skills/` directory.',
178+
'- Keep repo-root `_artifacts` as the reviewed plan.',
179+
'',
180+
'If maintainer confirms updates:',
181+
'1. Update the relevant `_artifacts/*domain_map.yaml` or `_artifacts/*skill_tree.yaml`.',
182+
'2. Update or create `SKILL.md` files only for confirmed coverage changes.',
183+
'3. Keep `sources` aligned between artifact skill entries and SKILL frontmatter.',
184+
'4. Bump `library_version` only for skills whose covered source package version changed.',
185+
'5. Run `npx @tanstack/intent@latest validate` on touched skill directories.',
186+
'6. Summarize every package as one of: existing-skill coverage, new skill, ignored, or deferred.',
187+
].join('\n')
188+
189+
const body = [
190+
'## Intent Skill Review Needed',
191+
'',
192+
'Intent found skills, artifact coverage, or workspace package coverage that need maintainer review.',
193+
'',
194+
'### Summary',
195+
'',
196+
'| Signal | Count |',
197+
'| --- | ---: |',
198+
...signalRows,
199+
'',
200+
'### Review Items',
201+
'',
202+
'| Signal | Subject | Library | Reason |',
203+
'| --- | --- | --- | --- |',
204+
...itemRows,
205+
'',
206+
'### Agent Prompt',
207+
'',
208+
'Paste this into your coding agent:',
209+
'',
210+
'```text',
211+
prompt,
212+
'```',
213+
'',
214+
'This PR is a review reminder only. It does not update skills automatically.',
215+
].join('\n')
216+
217+
fs.writeFileSync('pr-body.md', body + '\n')
218+
fs.writeFileSync(process.env.GITHUB_STEP_SUMMARY, body + '\n')
219+
NODE
220+
221+
- name: Open or update review PR
222+
if: steps.stale.outputs.has_review == 'true'
138223
env:
139224
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
140225
run: |
141226
VERSION="${{ github.event.release.tag_name || 'manual' }}"
142227
BRANCH="skills/review-${VERSION}"
228+
BASE_BRANCH="${{ github.event.repository.default_branch }}"
143229
144230
git config user.name "github-actions[bot]"
145231
git config user.email "41898282+github-actions[bot]@users.noreply.github.com"
146-
git checkout -b "$BRANCH"
147-
git commit --allow-empty -m "chore: review stale skills for ${VERSION}"
148-
git push origin "$BRANCH"
149-
150-
gh pr create \
151-
--title "Review stale skills (${VERSION})" \
152-
--body "$(cat <<'PREOF'
153-
## Stale Skills Detected
154232
155-
The following skills may need updates after the latest release:
156-
157-
${{ steps.summary.outputs.summary }}
158-
159-
---
160-
161-
### Update Prompt
162-
163-
Paste this into your coding agent (Claude Code, Cursor, etc.):
164-
165-
~~~
166-
${{ steps.summary.outputs.prompt }}
167-
~~~
233+
git fetch origin "$BRANCH" || true
234+
if git show-ref --verify --quiet "refs/remotes/origin/$BRANCH"; then
235+
git checkout -B "$BRANCH" "origin/$BRANCH"
236+
else
237+
git checkout -b "$BRANCH"
238+
git commit --allow-empty -m "chore: review intent skills for ${VERSION}"
239+
git push origin "$BRANCH"
240+
fi
168241
169-
PREOF
170-
)" \
171-
--head "$BRANCH" \
172-
--base main
242+
PR_URL="$(gh pr list --head "$BRANCH" --json url --jq '.[0].url')"
243+
if [ -n "$PR_URL" ]; then
244+
gh pr edit "$PR_URL" --body-file pr-body.md
245+
else
246+
gh pr create \
247+
--title "Review intent skills (${VERSION})" \
248+
--body-file pr-body.md \
249+
--head "$BRANCH" \
250+
--base "$BASE_BRANCH"
251+
fi

0 commit comments

Comments
 (0)