Add skill registry and on-demand script/reference loading#4
Merged
Conversation
- Scripts and references are no longer eagerly executed/loaded at skill activation. Only the SKILL.md body is included in context, with a manifest listing available scripts and references. - Add on-demand commands: /skill-run, /skill-ref, /skill-info in REPL - Add skill registry: download skills from npm, GitHub, or URLs via `ra skill install <source>`, with `ra skill remove` and `ra skill list` - Add buildSkillExcerpt() for compact skill summaries - Add readSkillReference() for on-demand reference loading - Add runSkillScriptByName() for on-demand script execution - Preserve buildSkillMessagesEager() as legacy API for eager loading - Update docs with registry and on-demand usage instructions https://claude.ai/code/session_016sNdNotWPJNobo9dPS9VUb
- Rewrite registry.ts: extract withTempExtract and installSkillDirs helpers to eliminate duplicated download-extract-install logic across npm/github/url - Replace shell-based copyDir with node:fs cpSync - Fix defaultSkillInstallDir to use os.homedir() instead of env vars - Fix scoped npm package URL encoding (don't encode @ in scope) - Use GitHub API tarball URL (auto-resolves default branch) - Fix removeSkill to use rmSync directly (no TOCTOU existence check) - Merge duplicate glob scans in findSkillDirsIn into single pattern - Add root-as-skill fallback to URL installer (was missing) - Extract resolveSkillAsset helper shared by runner.ts and loader.ts - Make registry.ts import lazy in index.ts (only loaded for skill subcommands) https://claude.ai/code/session_016sNdNotWPJNobo9dPS9VUb
f11eb96 to
49456e2
Compare
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
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
Summary
This PR introduces a skill registry system for installing skills from npm, GitHub, and URLs, along with a shift from eager to on-demand loading of skill scripts and references. Skills now include a manifest of available resources that can be loaded when needed, reducing initial context overhead.
Key Changes
Skill Registry (
src/skills/registry.ts)installSkill()function to download and install skills from npm, GitHub, or direct URLsparseSkillSource()to parse skill source strings (supportsnpm:,github:,https://, and bare package names)removeSkill()andlistInstalledSkills()for managing installed skillsdefaultSkillInstallDir()returns~/.ra/skillsas the default installation directory.source.json) with each installed skill for tracking origin and versionOn-Demand Script/Reference Loading
buildSkillMessages()now returns only the skill body with a manifest of available scripts and references, rather than executing all scripts eagerlybuildSkillMessagesEager()preserves the legacy behavior of running scripts at activation timerunSkillScriptByName()inrunner.tsallows running individual scripts on demandreadSkillReference()inloader.tsallows reading reference files on demandbuildSkillExcerpt()creates short summaries of skills for listingREPL Commands
/skill-run <skill> <script>- Execute a skill script and attach output to next message/skill-ref <skill> <reference>- Load a reference file and attach to next message/skill-info [name]- List all skills or show details for a specific skillCLI Commands
ra skill install <source>- Install from npm, GitHub, or URLra skill remove <name>- Remove an installed skillra skill list- List installed skills with source informationArgument Parsing
parseArgs()to recognize skill subcommandsSkillCommandinterface for skill management operationsDocumentation
docs/site/skills/index.mdwith registry installation instructions and on-demand loading patternsImplementation Details
SKILL.mdfiles in skill directories orskills/*/SKILL.mdsubdirectoriesmainandmasterbrancheshttps://claude.ai/code/session_016sNdNotWPJNobo9dPS9VUb