Skip to content

refactor(ai-skills): harden discovery + validation, dedupe fs helpers, docs#29

Merged
suleimansh merged 1 commit into
mainfrom
quality/ai-skills
Jun 26, 2026
Merged

refactor(ai-skills): harden discovery + validation, dedupe fs helpers, docs#29
suleimansh merged 1 commit into
mainfrom
quality/ai-skills

Conversation

@suleimansh

Copy link
Copy Markdown
Member

Code quality + docs pass for @gemstack/ai-skills (part of the per-package GemStack quality sweep).

Code quality

  • discover() resilience - a single unreadable or malformed SKILL.md no longer aborts the whole scan; the bad bundle is skipped and the rest are still indexed. Added an optional discover(root, { onError }) hook to observe what was skipped. This restores the documented "index hundreds of skills safely, run no skill code" contract.
  • Name validation - skill name is 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.)
  • Better errors - the undiscovered-name error lists available skills / hints to call discover(); loadSkill() separates a missing SKILL.md (ENOENT) from an unreadable one.
  • Dedupe - fileExists/isDirectory were defined twice; extracted into a shared fs-utils module.

Docs

  • README: clarified the tools module loads compiled (tools.js/.mjs/.cjs, not tools.ts); added a direct loadSkill() example and the onError note.

Verification

Added tests for discovery resilience and name validation. Build + 37 tests green. Minor changeset included (new DiscoverOptions surface).

…, 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.
@suleimansh suleimansh added the enhancement New feature or request label Jun 26, 2026
@suleimansh suleimansh self-assigned this Jun 26, 2026
@suleimansh suleimansh merged commit 3eb72d4 into main Jun 26, 2026
1 check passed
@suleimansh suleimansh deleted the quality/ai-skills branch June 26, 2026 19:51
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

enhancement New feature or request

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant