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>
114 lines
3.3 KiB
TypeScript
114 lines
3.3 KiB
TypeScript
import React from "react";
|
|
import { describe, it, expect } from "vitest";
|
|
import { render } from "./helpers/renderTui";
|
|
import { Tabs } from "../src/components/Tabs.js";
|
|
|
|
const noop = () => {};
|
|
|
|
describe("Tabs", () => {
|
|
it("renders the default visible tabs (auth + logging shown, requests hidden)", () => {
|
|
const { lastFrame } = render(
|
|
<Tabs activeTab="info" onTabChange={noop} width={120} />,
|
|
);
|
|
const frame = lastFrame() ?? "";
|
|
expect(frame).toContain("Info");
|
|
expect(frame).toContain("Auth");
|
|
expect(frame).toContain("Console");
|
|
expect(frame).toContain("Protocol");
|
|
// Network defaults to hidden
|
|
expect(frame).not.toContain("Network");
|
|
});
|
|
|
|
it("hides the auth tab when showAuth is false", () => {
|
|
const { lastFrame } = render(
|
|
<Tabs activeTab="info" onTabChange={noop} width={120} showAuth={false} />,
|
|
);
|
|
expect(lastFrame() ?? "").not.toContain("Auth");
|
|
});
|
|
|
|
it("hides the logging tab when showLogging is false", () => {
|
|
const { lastFrame } = render(
|
|
<Tabs
|
|
activeTab="info"
|
|
onTabChange={noop}
|
|
width={120}
|
|
showLogging={false}
|
|
/>,
|
|
);
|
|
expect(lastFrame() ?? "").not.toContain("Console");
|
|
});
|
|
|
|
it("shows the requests tab when showRequests is true", () => {
|
|
const { lastFrame } = render(
|
|
<Tabs
|
|
activeTab="info"
|
|
onTabChange={noop}
|
|
width={120}
|
|
showRequests={true}
|
|
/>,
|
|
);
|
|
expect(lastFrame() ?? "").toContain("Network");
|
|
});
|
|
|
|
it("hides the skills tab by default and shows it when showSkills is true", () => {
|
|
// A *server-declared* extension (SEP-2640), unlike the transport-derived
|
|
// gates above — it is only knowable after connecting, so the default has
|
|
// to be hidden.
|
|
const hidden = render(
|
|
<Tabs activeTab="info" onTabChange={noop} width={140} />,
|
|
);
|
|
expect(hidden.lastFrame() ?? "").not.toContain("Skills");
|
|
const shown = render(
|
|
<Tabs
|
|
activeTab="info"
|
|
onTabChange={noop}
|
|
width={140}
|
|
showSkills={true}
|
|
/>,
|
|
);
|
|
expect(shown.lastFrame() ?? "").toContain("Skills");
|
|
});
|
|
|
|
it("renders a count on the skills tab", () => {
|
|
const { lastFrame } = render(
|
|
<Tabs
|
|
activeTab="skills"
|
|
onTabChange={noop}
|
|
width={140}
|
|
showSkills={true}
|
|
counts={{ skills: 4 }}
|
|
/>,
|
|
);
|
|
expect(lastFrame() ?? "").toContain("Skills (4)");
|
|
});
|
|
|
|
it("marks the active tab with the ▶ marker", () => {
|
|
const { lastFrame } = render(
|
|
<Tabs activeTab="tools" onTabChange={noop} width={120} />,
|
|
);
|
|
expect(lastFrame() ?? "").toContain("▶");
|
|
});
|
|
|
|
it("renders counts when provided and omits them otherwise", () => {
|
|
const withCounts = render(
|
|
<Tabs
|
|
activeTab="info"
|
|
onTabChange={noop}
|
|
width={120}
|
|
counts={{ tools: 3, resources: 0 }}
|
|
/>,
|
|
);
|
|
const frame = withCounts.lastFrame() ?? "";
|
|
expect(frame).toContain("(3)");
|
|
// count of 0 is defined, so it still renders
|
|
expect(frame).toContain("(0)");
|
|
});
|
|
|
|
it("highlights the focused active tab", () => {
|
|
const { lastFrame } = render(
|
|
<Tabs activeTab="info" onTabChange={noop} width={120} focused={true} />,
|
|
);
|
|
// focused active tab path renders without error and shows the marker
|
|
expect(lastFrame() ?? "").toContain("▶");
|
|
});
|
|
});
|