refactor(ai-skills): harden discovery + validation, dedupe fs helpers, docs#29
Merged
Conversation
…, sharpen docs Code quality + docs pass for @gemstack/ai-skills: - discover() now skips an unreadable or malformed SKILL.md instead of failing the entire scan, with an optional onError hook to observe what was skipped. This restores the documented "index hundreds of skills safely, run no skill code" contract that a single bad bundle could break. - Skill name is validated at parse time against [a-zA-Z0-9_-] rather than being silently mangled later at compose time, so bad names fail fast. - The undiscovered-name error now lists available skills / hints to call discover() first; loadSkill() separates a missing SKILL.md from an unreadable one (ENOENT vs other errors). - Deduplicated fileExists/isDirectory into a shared fs-utils module. - README: tools module is loaded compiled (tools.js/.mjs/.cjs, not tools.ts); added a direct loadSkill() example and the onError note. Added tests for discovery resilience and name validation. 37 tests pass.
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.
Code quality + docs pass for
@gemstack/ai-skills(part of the per-package GemStack quality sweep).Code quality
discover()resilience - a single unreadable or malformedSKILL.mdno longer aborts the whole scan; the bad bundle is skipped and the rest are still indexed. Added an optionaldiscover(root, { onError })hook to observe what was skipped. This restores the documented "index hundreds of skills safely, run no skill code" contract.nameis validated at parse time against[a-zA-Z0-9_-]instead of being silently mangled later at compose time, so invalid names fail fast with a clear message. (Looser than Anthropic's kebab-case rule, so it never rejects a valid Anthropic skill.)discover();loadSkill()separates a missingSKILL.md(ENOENT) from an unreadable one.fileExists/isDirectorywere defined twice; extracted into a sharedfs-utilsmodule.Docs
tools.js/.mjs/.cjs, nottools.ts); added a directloadSkill()example and theonErrornote.Verification
Added tests for discovery resilience and name validation. Build + 37 tests green. Minor changeset included (new
DiscoverOptionssurface).