feat: Skills extension phase 3 — CLI, TUI, directory reads, frontmatter check
Closes #2248. Completes SEP-2640 support across all three clients, and closes the one obligation #2234 deliberately left open. - `checkSkillFrontmatterMatch` compares a served SKILL.md's own YAML frontmatter against the entry the listing advertised, field by field. No digest can cover this: a digest is taken over the bytes the server served, so it proves the file was not altered in transit and says nothing about whether the listing described it honestly. Needs a real YAML parser; `yaml` was already a root dependency, so this adds no package — but it does newly put it on core/'s import graph, hence the three bundler `external` lists. - `resources/directory/read`: result schemas defined against the normative text, `InspectorClient.readResourceDirectory`, a Directory section on the Skills screen, and `--method resources/directory/read` in the CLI. The client refuses the call locally when the server did not declare `directoryRead`, which is the SEP's MUST NOT. A child the directory lists but the entry does not is marked `not listed` rather than merged into the manifest — the SEP calls a directory result a live observation and forbids treating it as extending the manifest. - CLI: `skills/list`, `skills/get` and `resources/directory/read`, plus `--verify` — one NDJSON report per skill, a summary on stderr, exit 7 on a violation. Reads are sequential; a conforming manifest may declare 512 entries. - TUI: a Skills pane, shown only when the server declares the extension. Each row carries its conformance verdict as a glyph as well as a colour, since the pane is read over ssh and through script(1). Enter verifies. - `verifySkills` re-throws `AuthRecoveryRequiredError` rather than recording it per file: it says the session's authorization expired, so absorbing it would report N identical read failures and swallow the error the TUI and the web commands key off to reauthorize. Two open questions settled, both in code comments where they will be found: `skills/get` carries no caching attributes because SEP-2640 leaves the question open in as many words, so requiring them would fail a conforming server; and there is no `PagedSkillsState` because every consumer of this list is a whole-catalog verdict — computed over page one of three, "this server's skills conform" is not merely partial but wrong. The fixture grows two skills, both for checks that were otherwise undemonstrable: `lying-listing` (listing and file disagree, digest still verifies) and `stale-manifest` (serves a file its manifest does not declare). Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01ND46Ci64DC3tzBy9aG81Nc Signed-off-by: cliffhall <cliff@futurescale.com>
This commit is contained in:
parent
219a08e1b5
commit
9a8488681e
1 changed files with 4750 additions and 191 deletions
|
|
@ -24,6 +24,8 @@ const h = vi.hoisted(() => {
|
|||
resources: unknown[];
|
||||
resourceTemplates: unknown[];
|
||||
prompts: unknown[];
|
||||
skills: unknown[];
|
||||
skillsExtension: { directoryRead: boolean } | undefined;
|
||||
messages: unknown[];
|
||||
fetchRequests: unknown[];
|
||||
stderrLogs: unknown[];
|
||||
|
|
@ -39,6 +41,8 @@ const h = vi.hoisted(() => {
|
|||
resources: [],
|
||||
resourceTemplates: [],
|
||||
prompts: [],
|
||||
skills: [],
|
||||
skillsExtension: undefined as { directoryRead: boolean } | undefined,
|
||||
messages: [],
|
||||
fetchRequests: [],
|
||||
stderrLogs: [],
|
||||
|
|
@ -160,6 +164,10 @@ const h = vi.hoisted(() => {
|
|||
| "sse"
|
||||
| "streamable-http",
|
||||
);
|
||||
// The Skills tab is gated on a SERVER declaration, so the default here is
|
||||
// "not declared" — the tab is hidden unless a test opts in by pointing
|
||||
// `ctrl.skillsExtension` at a declaration.
|
||||
getSkillsExtension = vi.fn(() => ctrl.skillsExtension);
|
||||
authenticate = (...a: Parameters<InspectorClient["authenticate"]>) =>
|
||||
clientSpies.authenticate(...a);
|
||||
clearOAuthTokens = (
|
||||
|
|
@ -232,6 +240,11 @@ const h = vi.hoisted(() => {
|
|||
resourceTemplates: ctrl.resourceTemplates,
|
||||
})),
|
||||
useManagedPrompts: vi.fn(() => ({ prompts: ctrl.prompts })),
|
||||
useManagedSkills: vi.fn(() => ({
|
||||
skills: ctrl.skills,
|
||||
pageCount: ctrl.skills.length > 0 ? 1 : 0,
|
||||
error: null,
|
||||
})),
|
||||
useMessageLog: vi.fn(() => ({ messages: ctrl.messages })),
|
||||
useFetchRequestLog: vi.fn(() => ({ fetchRequests: ctrl.fetchRequests })),
|
||||
useStderrLog: vi.fn(() => ({ stderrLogs: ctrl.stderrLogs })),
|
||||
|
|
@ -246,6 +259,7 @@ vi.mock("@inspector/core/mcp/state/index.js", () => ({
|
|||
ManagedResourcesState: h.FakeManager,
|
||||
ManagedResourceTemplatesState: h.FakeManager,
|
||||
ManagedPromptsState: h.FakeManager,
|
||||
ManagedSkillsState: h.FakeManager,
|
||||
MessageLogState: h.FakeManager,
|
||||
FetchRequestLogState: h.FakeManager,
|
||||
StderrLogState: h.FakeManager,
|
||||
|
|
@ -271,6 +285,9 @@ vi.mock("@inspector/core/react/useManagedResources.js", () => ({
|
|||
vi.mock("@inspector/core/react/useManagedResourceTemplates.js", () => ({
|
||||
useManagedResourceTemplates: h.useManagedResourceTemplates,
|
||||
}));
|
||||
vi.mock("@inspector/core/react/useManagedSkills.js", () => ({
|
||||
useManagedSkills: h.useManagedSkills,
|
||||
}));
|
||||
vi.mock("@inspector/core/react/useManagedPrompts.js", () => ({
|
||||
useManagedPrompts: h.useManagedPrompts,
|
||||
}));
|
||||
|
|
@ -664,6 +681,8 @@ beforeEach(() => {
|
|||
resources: [],
|
||||
resourceTemplates: [],
|
||||
prompts: [],
|
||||
skills: [],
|
||||
skillsExtension: undefined as { directoryRead: boolean } | undefined,
|
||||
messages: [],
|
||||
fetchRequests: [],
|
||||
stderrLogs: [],
|
||||
|
|
@ -751,6 +770,42 @@ describe("App (foundation)", () => {
|
|||
expect(h.connect).toHaveBeenCalled();
|
||||
});
|
||||
|
||||
it("hides the Skills tab until the server declares the extension", async () => {
|
||||
// A *server*-declared extension (SEP-2640), so unlike the transport-derived
|
||||
// tabs it is only knowable after connecting — and showing it against a
|
||||
// server that never declared it would send `skills/list` to a server that
|
||||
// answers -32601 (#2248).
|
||||
h.ctrl.status = "connected";
|
||||
const r = await mount(oneStdio());
|
||||
await expectFrame(r, "Tools");
|
||||
expect(r.lastFrame() ?? "").not.toContain("Skills");
|
||||
});
|
||||
|
||||
it("shows the Skills tab, with its count, once the extension is declared", async () => {
|
||||
h.ctrl.status = "connected";
|
||||
h.ctrl.skillsExtension = { directoryRead: false };
|
||||
h.ctrl.skills = [
|
||||
{
|
||||
uri: "skill://demo/SKILL.md",
|
||||
frontmatter: { name: "demo", description: "d" },
|
||||
resources: [],
|
||||
},
|
||||
];
|
||||
const r = await mount(oneStdio());
|
||||
await expectFrame(r, "Skills (1)");
|
||||
});
|
||||
|
||||
it("opens the Skills tab with its 'k' accelerator", async () => {
|
||||
// `k`, not `s` — the accelerator has to appear in the label and stay
|
||||
// unique; see `tabsConfig.ts`.
|
||||
h.ctrl.status = "connected";
|
||||
h.ctrl.skillsExtension = { directoryRead: true };
|
||||
const r = await mount(oneStdio());
|
||||
await expectFrame(r, "Skills");
|
||||
r.stdin.write("k");
|
||||
await expectFrame(r, "Select a skill to view details");
|
||||
});
|
||||
|
||||
it("disconnects with 'd' when connected", async () => {
|
||||
h.ctrl.status = "connected";
|
||||
const { stdin } = await mount(oneStdio());
|
||||
|
|
|
|||
Loading…
Reference in a new issue