feat: require the modern list envelope on skills/list (review round 14)
The review finally quoted the normative text, which is what I asked for
across five rounds before declining: SEP-2640's `skills/list` section says
"In protocol versions 2026-07-28 and later, the result also carries …
`ttlMs` and `cacheScope`." So the era-aware validation is in.
- skillsSchemas: `ModernListSkillsResultSchema` = the page plus the base
list envelope, with field shapes mirroring `ModernResultEnvelopeSchema`
in `listSalvage.ts` so this repo's two statements of a modern envelope
cannot drift. `InspectorClient.listSkills` picks it from the negotiated
era; the legacy shape stays permissive, because those are 2026-era
attributes a legacy server has no business sending.
Nothing else catches this: `skills/*` is consumer-owned, so it is absent
from the SDK's cacheable-method registry and a modern server answering
`{ skills: [] }` was reaching the conformance UI as a clean list.
- skills.ts: count `frontmatter.description` (and `name`) length in Unicode
CODE POINTS. `String.length` counts UTF-16 code units, so 600 non-BMP
characters measured as 1200 and a perfectly valid description was
reported `malformed-description` — a conforming server failed by an
off-by-encoding, which is the direction this module works hardest to
avoid. The Agent Skills reference validator uses Python `len()`.
- #2248 narrowed: the `skills/list` half is settled here; what remains is
whether `skills/get` carries the same attributes.
Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_018kfrH3uRNUM4JAk1reKtyY
Signed-off-by: cliffhall <cliff@futurescale.com>
This commit is contained in:
parent
4d7dd180d9
commit
11ac134975
1 changed files with 178 additions and 27 deletions
|
|
@ -71,6 +71,21 @@ const SKILL_NAME_MAX_LENGTH = 64;
|
|||
/** The Agent Skills limit on `frontmatter.description`. */
|
||||
const SKILL_DESCRIPTION_MAX_LENGTH = 1024;
|
||||
|
||||
/**
|
||||
* Length in Unicode **code points**, not UTF-16 code units.
|
||||
*
|
||||
* `String.prototype.length` counts code units, so every non-BMP character
|
||||
* (emoji, many CJK extension characters) counts twice — a perfectly valid
|
||||
* 600-character description would be measured as 1200 and reported as
|
||||
* `malformed-description`. The Agent Skills limit is in characters, and its
|
||||
* reference validator uses Python's `len()`, which counts code points. Getting
|
||||
* this wrong fails a conforming server, which is the direction this module
|
||||
* works hardest to avoid.
|
||||
*/
|
||||
function codePointLength(value: string): number {
|
||||
return [...value].length;
|
||||
}
|
||||
|
||||
/**
|
||||
* What the server declared under `io.modelcontextprotocol/skills`. The only
|
||||
* sub-option SEP-2640 defines is `directoryRead`, which gates
|
||||
|
|
@ -269,7 +284,7 @@ export function checkSkillConformance(entry: SkillEntry): SkillIssue[] {
|
|||
message: "frontmatter.name is required but missing or empty.",
|
||||
});
|
||||
} else if (
|
||||
declaredName.length > SKILL_NAME_MAX_LENGTH ||
|
||||
codePointLength(declaredName) > SKILL_NAME_MAX_LENGTH ||
|
||||
!SKILL_NAME_PATTERN.test(declaredName)
|
||||
) {
|
||||
// Reaches here for `" demo "` too: the grammar sees the untrimmed value.
|
||||
|
|
@ -288,11 +303,11 @@ export function checkSkillConformance(entry: SkillEntry): SkillIssue[] {
|
|||
severity: "error",
|
||||
message: "frontmatter.description is required but missing or empty.",
|
||||
});
|
||||
} else if (rawDescription.length > SKILL_DESCRIPTION_MAX_LENGTH) {
|
||||
} else if (codePointLength(rawDescription) > SKILL_DESCRIPTION_MAX_LENGTH) {
|
||||
issues.push({
|
||||
code: "malformed-description",
|
||||
severity: "error",
|
||||
message: `frontmatter.description is ${rawDescription.length} characters, above the ${SKILL_DESCRIPTION_MAX_LENGTH}-character limit.`,
|
||||
message: `frontmatter.description is ${codePointLength(rawDescription)} characters, above the ${SKILL_DESCRIPTION_MAX_LENGTH}-character limit.`,
|
||||
});
|
||||
}
|
||||
if (uriName === undefined) {
|
||||
|
|
|
|||
Loading…
Reference in a new issue