Repository navigation
Check that each skill is up to date on first use #26
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
Open
njb90
wants to merge
11
commits into
main
Choose a base branch
from
feat/version-check
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
Show all changes
11 commits
Select commit
Hold shift + click to select a range
752fda3
Add a version check to every skill
njb90 57f413b
Run the discovery check on Node 22
njb90 d12e524
Update templates/version-check.md
njb90 eb7e354
Add more purpose options with descriptions to aid the agent in choosi…
njb90 61123ce
Expand cloud name check to more locations
njb90 a10b5f1
Fix version check indentation
njb90 8eba130
Add logical timeout for request
njb90 272b903
Calrify the response is data not instructional.
njb90 2a7a5a7
Add opt-out clarification
njb90 24c0de0
Merge branch 'main' into feat/version-check
njb90 9e8fbe7
Add TRIGGER to skill descriptions -
jackieros File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,56 @@ | ||
| #!/usr/bin/env bash | ||
| # Every SKILL.md must carry the version-check block rendered from | ||
| # templates/version-check.md, directly under its H1. {{name}} and | ||
| # {{version}} come from the frontmatter; {{referrer}} is the referrer its doc links already use, or | ||
| # <name without cloudinary->-skill if it has none. | ||
| # Usage: scripts/check-version-block.sh [--fix] (--fix rewrites the blocks) | ||
| set -u | ||
| root="$(cd "$(dirname "$0")/.." && pwd)" | ||
| template="$root/templates/version-check.md" | ||
| fix=0; [ "${1:-}" = "--fix" ] && fix=1 | ||
|
|
||
| render() { # <name> <referrer> <version> -> rendered block on stdout | ||
| sed -e "s/{{name}}/$1/g" -e "s/{{referrer}}/$2/g" -e "s/{{version}}/$3/g" "$template" | ||
| } | ||
| strip_block() { # <file> -> file without the block (and the blank line after it) | ||
| awk '/<!-- version-check:start/{skip=1; next} | ||
| skip{if (/<!-- version-check:end -->/) {skip=0; drop=1}; next} | ||
| drop{drop=0; if ($0 == "") next} | ||
| {print}' "$1" | ||
| } | ||
| insert_block() { # <file without block> <block file> -> file with block after the H1 | ||
| awk -v blk="$2" 'BEGIN{done=0} | ||
| {print} | ||
| !done && /^# /{getline nxt; print ""; while ((getline l < blk) > 0) print l; print ""; if (nxt != "") print nxt; done=1}' "$1" | ||
| } | ||
|
|
||
| fail=0 | ||
| tmp=$(mktemp -d); trap 'rm -rf "$tmp"' EXIT | ||
| while IFS= read -r md; do | ||
| # Read both keys from the leading frontmatter only, at any indentation. | ||
| name=$(sed -nE '1,/^---$/{s/^[[:space:]]*name:[[:space:]]*['"'"'"]?([^'"'"'"]+)['"'"'"]?[[:space:]]*$/\1/p;}' "$md" | head -1) | ||
| version=$(sed -nE '1,/^---$/{s/^[[:space:]]+version:[[:space:]]*['"'"'"]?([^'"'"'"]+)['"'"'"]?[[:space:]]*$/\1/p;}' "$md" | head -1) | ||
| if [ -z "$name" ] || [ -z "$version" ]; then | ||
| echo "::error file=${md#"$root"/}::Could not read name or metadata.version from the frontmatter, so the version-check block can't be rendered." | ||
| fail=1; continue | ||
| fi | ||
| dir=$(dirname "$md") | ||
| referrer=$(grep -rhoE 'referrer=[A-Za-z0-9_-]+' "$dir" | sed 's/referrer=//' | sort | uniq -c | sort -rn | awk 'NR==1{print $2}') | ||
| [ -n "$referrer" ] || referrer="${name#cloudinary-}-skill" | ||
|
|
||
| render "$name" "$referrer" "$version" > "$tmp/block" | ||
| strip_block "$md" > "$tmp/bare" | ||
| insert_block "$tmp/bare" "$tmp/block" > "$tmp/want" | ||
|
|
||
| if ! cmp -s "$md" "$tmp/want"; then | ||
| if [ "$fix" -eq 1 ]; then | ||
| cp "$tmp/want" "$md"; echo "fixed $name" | ||
| else | ||
| echo "::error file=${md#"$root"/}::$name's version-check block is missing, out of date (for example after a version bump), or not directly under the H1. Run scripts/check-version-block.sh --fix." | ||
| fail=1 | ||
| fi | ||
| else | ||
| echo "ok $name" | ||
| fi | ||
| done < <(find "$root/skills" -name SKILL.md | LC_ALL=C sort) | ||
| exit $fail |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.