-
Notifications
You must be signed in to change notification settings - Fork 1
fix: use per-skill discovery URL in installCommand #50
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
johnmcollier
merged 1 commit into
redhat-ai-dev:main
from
johnmcollier:fix/install-command-skill-flag
Jul 16, 2026
Merged
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
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
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -9,6 +9,7 @@ import type { Repositories } from "../db/init.js"; | |
| import { createAdminAuthHook } from "../plugins/adminAuth.js"; | ||
| import { ingestSource } from "../ingestion/ingest.js"; | ||
| import { resolveBaseUrl } from "../utils/resolveBaseUrl.js"; | ||
| import { buildDiscoveryIndex, toDiscoverySkillEntry } from "../utils/discoveryIndex.js"; | ||
|
|
||
| /** | ||
| * Decode a base64 tar.gz archive and return all contained files as | ||
|
|
@@ -50,11 +51,12 @@ async function expandArchiveToFiles( | |
| } | ||
|
|
||
| function skillToResponse(skill: Skill, source: Source | undefined, baseUrl: string) { | ||
| // Point at the host so the CLI discovers via /.well-known/agent-skills/index.json, | ||
| // then select this skill. Artifact URLs are not a valid skills-add source by themselves | ||
| // and would make the CLI fetch every skill in the index. | ||
| // Use --skill=<id> (single argv token) so odd slug characters cannot split the command. | ||
| const installCommand = `npx skills add ${baseUrl} --skill=${skill.slug}`; | ||
| // Point at the per-skill discovery URL. The CLI looks for | ||
| // <url>/.well-known/agent-skills/index.json first; that single-entry index | ||
| // auto-selects this skill. Host root + `--skill=…` fails because the skills CLI | ||
| // does not parse the equals form of --skill, and would download the full catalog. | ||
| const installCommand = | ||
| `npx skills add ${baseUrl}/api/v1/skills/${encodeURIComponent(skill.sourceSlug)}/${encodeURIComponent(skill.slug)}`; | ||
| return { | ||
| id: skill.id, | ||
| source: skill.sourceSlug, | ||
|
|
@@ -117,7 +119,8 @@ const skillSchema = { | |
| frontmatter: { type: "object", additionalProperties: true, description: "Full parsed frontmatter map (excluding name/description)" }, | ||
| installCommand: { | ||
| type: "string", | ||
| description: "npx skills add <host> --skill <slug> command to install this skill via well-known discovery", | ||
| description: | ||
| "npx skills add <skill-discovery-url> command; the URL serves a single-entry well-known index", | ||
| }, | ||
| lastModified: { type: "string", description: "ISO 8601 timestamp of last update" }, | ||
| }, | ||
|
|
@@ -269,6 +272,83 @@ const skillsPlugin: FastifyPluginAsync<SkillsRouteOptions> = async (fastify, opt | |
| } | ||
| ); | ||
|
|
||
| // Per-skill discovery index — registered before /:source/:slug. | ||
| // Consumed by `npx skills add <base>/api/v1/skills/:source/:slug`, which probes | ||
| // `<url>/.well-known/agent-skills/index.json` before falling back to the host root. | ||
| fastify.get( | ||
| "/:source/:slug/.well-known/agent-skills/index.json", | ||
| { | ||
|
Comment on lines
+275
to
+280
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 2. Openapi not regenerated A new discovery endpoint (GET /api/v1/skills/:source/:slug/.well-known/agent-skills/index.json) was added, but the committed openapi.yaml (generated via npm run openapi) does not document it, so tooling/consumers relying on the checked-in spec will miss the endpoint. Agent Prompt
|
||
| schema: { | ||
| tags: ["Discovery"], | ||
| summary: "Single-skill Agent Skills discovery index", | ||
| description: | ||
| "Returns a one-entry discovery manifest for this skill so `npx skills add` " + | ||
| "can install it without downloading the full catalog.", | ||
| params: { | ||
| type: "object", | ||
| required: ["source", "slug"], | ||
| properties: { | ||
| source: { type: "string" }, | ||
| slug: { type: "string" }, | ||
| }, | ||
| }, | ||
| response: { | ||
| 200: { | ||
| type: "object", | ||
| properties: { | ||
| $schema: { type: "string" }, | ||
| skills: { | ||
| type: "array", | ||
| items: { | ||
| type: "object", | ||
| properties: { | ||
| name: { type: "string" }, | ||
| type: { type: "string", enum: ["skill-md", "archive"] }, | ||
| description: { type: "string" }, | ||
| url: { type: "string", format: "uri" }, | ||
| digest: { type: "string" }, | ||
| }, | ||
| required: ["name", "type", "description", "url", "digest"], | ||
| }, | ||
| }, | ||
| }, | ||
| }, | ||
| 404: errorSchema, | ||
| }, | ||
| }, | ||
| }, | ||
| async ( | ||
| req: FastifyRequest<{ Params: { source: string; slug: string } }>, | ||
| reply: FastifyReply | ||
| ) => { | ||
| const { source, slug } = req.params; | ||
| const skill = skills.findBySourceAndSlug(source, slug); | ||
| if (!skill) { | ||
| return reply.code(404).send({ | ||
| error: { code: "SKILL_NOT_FOUND", message: `Skill '${source}/${slug}' not found.` }, | ||
| }); | ||
| } | ||
| const baseUrl = resolveBaseUrl(req); | ||
| const discoverySkill = { | ||
| sourceSlug: skill.sourceSlug, | ||
| slug: skill.slug, | ||
| name: skill.name, | ||
| description: skill.description, | ||
| artifactType: skill.artifactType, | ||
| digest: skill.digest, | ||
| }; | ||
| if (!toDiscoverySkillEntry(discoverySkill, baseUrl)) { | ||
| return reply.code(404).send({ | ||
| error: { | ||
| code: "SKILL_NOT_INSTALLABLE", | ||
| message: `Skill '${source}/${slug}' has an install id that is incompatible with npx skills.`, | ||
| }, | ||
| }); | ||
| } | ||
| return reply.send(buildDiscoveryIndex([discoverySkill], baseUrl)); | ||
| } | ||
| ); | ||
|
|
||
| // Artifact download — registered before /:source/:slug (static suffix wins) | ||
| fastify.get( | ||
| "/:source/:slug/artifact", | ||
|
|
||
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
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,45 @@ | ||
| import type { SkillDiscoveryEntry } from "../db/types.js"; | ||
| import { isValidSkillInstallId } from "./skillInstallId.js"; | ||
|
|
||
| export const DISCOVERY_SCHEMA = | ||
| "https://schemas.agentskills.io/discovery/0.2.0/schema.json"; | ||
|
|
||
| export interface DiscoverySkillEntry { | ||
| name: string; | ||
| type: "skill-md" | "archive"; | ||
| description: string; | ||
| url: string; | ||
| digest: string; | ||
| } | ||
|
|
||
| /** Map a DB discovery row to a CLI-compatible index entry, or null if unusable. */ | ||
| export function toDiscoverySkillEntry( | ||
| skill: SkillDiscoveryEntry, | ||
| baseUrl: string, | ||
| ): DiscoverySkillEntry | null { | ||
| if (!isValidSkillInstallId(skill.slug)) return null; | ||
| return { | ||
| // Discovery `name` must be a kebab-case install id ([a-z0-9-]+). | ||
| name: skill.slug, | ||
| type: skill.artifactType, | ||
| // CLI rejects descriptions longer than 1024 characters. | ||
| description: | ||
| skill.description.length > 1024 | ||
| ? `${skill.description.slice(0, 1023)}…` | ||
| : skill.description, | ||
| url: `${baseUrl}/api/v1/skills/${encodeURIComponent(skill.sourceSlug)}/${encodeURIComponent(skill.slug)}/artifact`, | ||
| digest: `sha256:${skill.digest}`, | ||
| }; | ||
| } | ||
|
|
||
| export function buildDiscoveryIndex( | ||
| entries: SkillDiscoveryEntry[], | ||
| baseUrl: string, | ||
| ): { $schema: string; skills: DiscoverySkillEntry[] } { | ||
| return { | ||
| $schema: DISCOVERY_SCHEMA, | ||
| skills: entries | ||
| .map((s) => toDiscoverySkillEntry(s, baseUrl)) | ||
| .filter((s): s is DiscoverySkillEntry => s !== null), | ||
| }; | ||
| } |
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
Oops, something went wrong.
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.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
1. Web spec install drift
🐞 Bug⚙ MaintainabilityAgent Prompt
ⓘ Copy this prompt and use it to remediate the issue with your preferred AI generation tools