Repository navigation
feat(blocks-api): add throttled self-update freshness check - #4
Conversation
Add scripts/skill-freshness-check.sh to the blocks-api skill. The agent runs it once per invocation; it refreshes the installed skill via the skills CLI at most once a day, retries failures after 15 minutes, backs off to daily after three failures in a row, and always exits 0. It prints a single note only when the skill files actually changed. The update runs from the directory that owns the .agents tree so the CLI sees both global and project installs, and the skill contents are checksummed before and after because the CLI reports "Updated" for project installs even when nothing changed. Also add a bash test harness for the script, run it and shellcheck in CI, document the opt-out in the README, and bump the skill to 0.2.0. Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
|
This pull request was created from a Blocks session. View in dashboard | View on desktop
|
|
@blocks /claude why is the https://github.com/BlocksOrg/skills/actions/runs/37389236107/job/112032059059?pr=4 failing ? |
|
That job is failing because of a CodeQL setting on the repo. Nothing in this PR's code causes it. The error The analysis itself ran fine. It failed at the end, when it tried to upload its results: Why The repo has two CodeQL setups running at once, and GitHub only allows one:
When default setup is on, GitHub rejects results uploaded by an advanced-setup workflow. So this job will fail on every PR and every push to Fix (pick one)
The second option needs a separate PR to |
|
You are seeing this message because GitHub Code Scanning has recently been set up for this repository, or this pull request contains the workflow file for the Code Scanning tool. What Enabling Code Scanning Means:
For more information about GitHub Code Scanning, check out the documentation. |
The freshness check only applied its 120s deadline where `timeout` was on PATH, which excludes stock macOS. Replace it with a bash watchdog: the update runs in its own process group under job control, a sibling subshell kills that group when the deadline passes, and a hit deadline is recorded as a failure so the normal backoff applies. Expose BLOCKS_SKILLS_TIMEOUT for tests and add a hang scenario to the harness that checks exit 0, no output, a bounded wall clock, the whole process tree being killed, and the 15-minute retry. Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
|
@cube /claude /reviewreview |
|
There are 2 inline review threads on PR #4, both from the bot reviewer and both on
The other top-level comments aren't review findings: the PR-created notice, the CodeQL failure question (already answered), the code-scanning bot, and your two requests. 1. Concurrent sessions can both run the update (5 → 3)
2. No update deadline on stock macOS (6 → 2)
Next stepTell me which to pick: 1, 2 (only the small cleanups, since the main fix is already in), both, or neither. Then I'll:
|
|
User Message:
I've fixed issue 1 and pushed it to The fix for issue 1 is in
Tests: I added 7 checks to the test script, which now has 50. All pass, five runs in a row, and shellcheck is clean. Against the previous script, 3 of the new checks fail:
GitHub threads:
PR description: a "Review triage" section with one line per issue (picked or not picked, with the score change) now sits at the bottom, just above the "Generated with Claude Code" line. The rest of the description is unchanged, so it still says "36 checks" in two places, which is now out of date. |
Agent sessions starting within a few milliseconds of each other could all read the marker before any of them wrote it, so each ran its own `skills update` against the same install. Take an atomic mkdir lock before reading the marker and hold it through the update; runs that find it held skip immediately, and a lock older than the deadline plus a minute is taken over. Adds concurrent, held-lock and stale-lock tests (50 checks). Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Summary
The
blocks-apiskill now keeps itself up to date. A newscripts/skill-freshness-check.shlives inside the skill directory (sonpx skills addships it), andSKILL.mdgains a "Step 0" telling the agent to run it once before anything else.What the script does:
npx --yes skills@1.7.0 update blocks-api -yat most once every 24 hours. After a failure it retries 15 minutes later; after three failures in a row it backs off to one attempt per day. State is a small marker file under${XDG_CACHE_HOME:-~/.cache}/blocks-skills/<hash-of-scope-root>/.pwd -P, so the~/.claude/skillssymlink is followed) and walks up to the directory that owns the.agents/tree, then runs the update from there. With a skill name and no-g/-p, the CLI checks both the global lock and the project lock in the current directory, so one command covers both install styles.SKILL.md,references/*.mdandscripts/*.shbefore and after. The CLI prints "Updated" for project installs even when nothing changed, so the checksum is the real signal. It also scans the output for failure wording because the CLI exits 0 on most of its own error paths.set -e, every path exits 0, nothing on stdout unless the skill files actually changed (then exactly one line the agent relays to the user). Missingnpx, an unwritable cache dir, or an untracked install all skip quietly.BLOCKS_SKILLS_NO_UPDATE=1opts out,BLOCKS_SKILLS_DEBUG=1logs every decision to stderr, andBLOCKS_SKILLS_NOW/BLOCKS_SKILLS_UPDATE_CMD/BLOCKS_SKILLS_ROOTexist for the tests.Also in this PR:
scripts/skill-freshness-check.test.sh: a bash harness with a fake clock and a fake update command (36 checks covering first run, 24h throttle, 15m retry, daily back-off after 3 failures, success resetting the counter, non-zero exit, "not installed" output, opt-out, missing command, unwritable cache, stdout/stderr separation).validatejob:shellcheckoverinstall.shandskills/*/scripts/*.sh, plus a step that runs the test harness.metadata.versionbumped to0.2.0.Linked issue
Fixes #
How I verified
blocks-apiglobally from GitHub and confirmednpx skills@1.7.0 update blocks-api -ywith no scope flag finds the global install from~("All global skills are up to date"), finds both scopes from a project root, and finds only global when run from inside the skill directory. That drove the walk-up-to-root logic.~/.claude/skills/blocks-apisymlink: first run hit upstream and was silent (no change), second run skipped ("checked successfully 1s ago"), a run with the clock pushed 25h ahead checked again and stayed silent.bash skills/blocks-api/scripts/skill-freshness-check.test.sh: 36 passed, 0 failed.shellcheckclean on both scripts andinstall.sh.npx skills@1.7.0 add . --liststill listsblocks-api.Known edge: the update overwrites the running script itself. Fine on Linux and macOS (the open file handle survives); on Windows Git Bash a locked file would just register as one failure and be retried later.
Checklist
npx skills add . --listlists every skill underskills/namematches the skill directory anddescriptionsays when to triggerhttps://api.blocks.teamand$BLOCKS_API_KEY; no real keys or internal hoststype(scope): summary)Review triage
mkdirlock and a concurrency test.🤖 Generated with Claude Code