feat(ai-skills): add @gemstack/ai-skills — portable capability bundles#16
Merged
Conversation
Second package of the AI family (#8). Loads SKILL.md skills (instructions + tools + resources) and composes them onto an @gemstack/ai-sdk Agent. - manifest: SKILL.md YAML frontmatter + markdown body (matches boost/skills + Anthropic Agent Skills shape), zod-validated. - loader: loadSkill/loadSkills — instructions, co-located tool() exports, resources/. - registry: SkillRegistry discovers skills by cheap frontmatter and loads the full body + tools on demand (progressive disclosure). - compose: composeInstructions/Tools/Middleware merge skills into an agent; the agent's own declarations stay authoritative (own tools win collisions, skill tools namespaced as backstop). SkillfulAgent base wraps this declaratively. - trust boundary: no in-process sandbox; discovery runs no skill code, loadTools:false surfaces without executing, tool exec stays on the agent's approval/middleware path. One-directional (ai-skills -> ai-sdk). 33 tests incl. an end-to-end run proving ai-sdk delivers the composed system prompt + skill tools to the provider. Closes #8
10 tasks
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.
Implements #8 — the second package of the GemStack AI family. Loads
SKILL.mdskills (instructions + tools + resources) and composes them onto an@gemstack/ai-sdkAgent. Greenfield: builds the registry + loader + runtime around the existingboost/skillsconvention.Surface
parseSkillManifest():SKILL.mdYAML frontmatter + markdown body, zod-validated. Matches the shippedboost/skillsconvention and the Anthropic Agent Skills shape (a skill authored for Claude loads here; a gemstack skill ships as a plain folder).loadSkill()/loadSkills(): a skill dir's instructions, co-locatedtool()exports, andresources/.SkillRegistry: discover skills by their cheap frontmatter, load the full body + tools on demand (progressive disclosure — index hundreds, pay for what you compose).composeInstructions/composeTools/composeMiddleware+surface. The agent's own declarations stay authoritative: own tools win name collisions; colliding skill tools are namespaced (<skill>__<tool>) rather than dropped.SkillfulAgent— anAgentbase that composesskills()declaratively alongsidebaseInstructions()/baseTools()/baseMiddleware().Design decisions honored (Architecture.md / #8)
SKILL.mdfrontmatter, not a TS-first definition — zero divergence from the shipped convention; progressive disclosure falls out (index frontmatter, load body on demand).ai-sdktool()directly via a co-locatedtools.ts; the loader imports + merges. One tool API across the framework.discover()runs no code;loadTools: false;surface()); the risky moment (tool execution) stays on the agent's existing approval/middleware path.The composition seam (why
SkillfulAgentworks)ai-skillsdepends onai-sdk, never the reverse, so it can't add askills()hook to theAgentbase. I traced the read sites: ai-sdk readsinstructions()(abstract) andgetTools(a)at loop construction (tools are frozen there — middleware can't add tools). SoSkillfulAgentsealsinstructions()/tools()/middleware()as composing finals over user-authoredbaseInstructions()/baseTools()/skills(). The low-levelcompose*helpers are the same merge for anyone who can't extend the base.Verification
pnpm build+pnpm typecheck— all 3 packages ✓AiFakerun asserting ai-sdk delivers the composed system prompt and skill tools to the provider.ai-sdkreferencesai-skillsnowhere.Changeset:
@gemstack/ai-skillsminor → 0.1.0.Follow-up design options remain low-priority and out of scope: TS-first
defineSkill(#11),skillTool()wrapper (#12), imperativeagent.use()(#13).