Context
apps/loopover-ui/src/lib/mcp-package.ts provides the pure logic behind the two places the site tells
visitors which @loopover/mcp version to install: components/site/mcp-version-badge.tsx (the header
badge, showing a version dropdown) and components/site/npm-install.tsx (the copyable install
command). It has no React/DOM dependency in its exported helper functions:
isStableVersion(version) — regex-gates a version string to \d+\.\d+\.\d+ (excludes prereleases
like 3.12.0-beta.1 from ever being shown as "latest" or offered in the install command).
getLatestMcpVersion(data) — falls back to the hardcoded MCP_PACKAGE_KNOWN_LATEST_VERSION when
data is undefined, when dist-tags.latest is absent, or when it's present but not a stable
version.
getRecentMcpVersions(data, limit = 6) — filters to stable versions with a known publish time, sorts
descending by publish date (string comparison of ISO timestamps via localeCompare), and slices to
limit; falls back to [MCP_PACKAGE_KNOWN_LATEST_VERSION] when data is undefined.
getMcpInstallCommand(version?) / getMcpNpxPackage(version?) — pin to the given version only when
it's both present and stable, otherwise fall back to @latest.
None of these five functions has a test anywhere in the repo (no mcp-package.test.ts exists, and no
existing *.test.ts* file references mcp-package, getLatestMcpVersion, getRecentMcpVersions,
isStableVersion, or getMcpInstallCommand). Both consuming components
(components/site/mcp-version-badge.tsx, components/site/npm-install.tsx) are themselves untested,
so there is currently no automated coverage anywhere in the repo for "does the site ever recommend
installing a prerelease build" or "does the badge correctly fall back when npm is unreachable."
Requirements
- Add
apps/loopover-ui/src/lib/mcp-package.test.ts covering:
isStableVersion: accepts "3.11.0"; rejects "3.11.0-beta.1", "3.11", "v3.11.0", "", and
a non-numeric string.
getLatestMcpVersion: returns dist-tags.latest when present and stable; falls back to
MCP_PACKAGE_KNOWN_LATEST_VERSION when data is undefined, when dist-tags.latest is absent,
and when dist-tags.latest is present but unstable (a prerelease tag must never surface as
"latest").
getRecentMcpVersions: returns [MCP_PACKAGE_KNOWN_LATEST_VERSION] when data is undefined;
excludes unstable versions and versions missing a time entry; sorts strictly by descending
publish time (construct fixture data where insertion order and time order differ, to actually
exercise the sort, not just confirm array order matches input order); respects a custom limit
and defaults to 6.
getMcpInstallCommand / getMcpNpxPackage: pin to the given version when stable; fall back to
@latest / @loopover/mcp@latest when version is undefined and when version is an unstable
string.
Deliverables
Test Coverage Requirements
apps/** is outside this repo's Codecov coverage.include (vitest.config.ts / codecov.yml's
ignore: ["apps/**", ...]), so this change owes no Codecov patch-coverage percentage. Aim for genuine
branch coverage of every conditional in the five functions listed above (both sides of each ?/??
fallback), since a one-line regex or fallback-order mistake here is exactly the kind of thing branch
coverage catches and line coverage doesn't. Run
npx vitest run apps/loopover-ui/src/lib/mcp-package.test.ts while iterating, and npm run ui:test
before opening the PR.
Expected Outcome
The version-selection logic that decides what install command and "latest" badge every visitor to the
site sees has a real regression suite, so a future change (e.g. adjusting the stable-version regex, or
changing the sort/fallback order) that accidentally started recommending a prerelease build as
"latest" would fail a test instead of shipping silently.
Links & Resources
apps/loopover-ui/src/lib/mcp-package.ts (the module to test)
apps/loopover-ui/src/components/site/mcp-version-badge.tsx and
apps/loopover-ui/src/components/site/npm-install.tsx (the real call sites)
apps/loopover-ui/src/lib/config-generator-yaml.test.ts for this repo's established plain-vitest,
no-React pure-function test pattern
Context
apps/loopover-ui/src/lib/mcp-package.tsprovides the pure logic behind the two places the site tellsvisitors which
@loopover/mcpversion to install:components/site/mcp-version-badge.tsx(the headerbadge, showing a version dropdown) and
components/site/npm-install.tsx(the copyable installcommand). It has no React/DOM dependency in its exported helper functions:
isStableVersion(version)— regex-gates a version string to\d+\.\d+\.\d+(excludes prereleaseslike
3.12.0-beta.1from ever being shown as "latest" or offered in the install command).getLatestMcpVersion(data)— falls back to the hardcodedMCP_PACKAGE_KNOWN_LATEST_VERSIONwhendatais undefined, whendist-tags.latestis absent, or when it's present but not a stableversion.
getRecentMcpVersions(data, limit = 6)— filters to stable versions with a known publish time, sortsdescending by publish date (string comparison of ISO timestamps via
localeCompare), and slices tolimit; falls back to[MCP_PACKAGE_KNOWN_LATEST_VERSION]whendatais undefined.getMcpInstallCommand(version?)/getMcpNpxPackage(version?)— pin to the given version only whenit's both present and stable, otherwise fall back to
@latest.None of these five functions has a test anywhere in the repo (no
mcp-package.test.tsexists, and noexisting
*.test.ts*file referencesmcp-package,getLatestMcpVersion,getRecentMcpVersions,isStableVersion, orgetMcpInstallCommand). Both consuming components(
components/site/mcp-version-badge.tsx,components/site/npm-install.tsx) are themselves untested,so there is currently no automated coverage anywhere in the repo for "does the site ever recommend
installing a prerelease build" or "does the badge correctly fall back when npm is unreachable."
Requirements
apps/loopover-ui/src/lib/mcp-package.test.tscovering:isStableVersion: accepts"3.11.0"; rejects"3.11.0-beta.1","3.11","v3.11.0","", anda non-numeric string.
getLatestMcpVersion: returnsdist-tags.latestwhen present and stable; falls back toMCP_PACKAGE_KNOWN_LATEST_VERSIONwhendataisundefined, whendist-tags.latestis absent,and when
dist-tags.latestis present but unstable (a prerelease tag must never surface as"latest").
getRecentMcpVersions: returns[MCP_PACKAGE_KNOWN_LATEST_VERSION]whendataisundefined;excludes unstable versions and versions missing a
timeentry; sorts strictly by descendingpublish time (construct fixture data where insertion order and time order differ, to actually
exercise the sort, not just confirm array order matches input order); respects a custom
limitand defaults to 6.
getMcpInstallCommand/getMcpNpxPackage: pin to the given version when stable; fall back to@latest/@loopover/mcp@latestwhenversionisundefinedand whenversionis an unstablestring.
Deliverables
apps/loopover-ui/src/lib/mcp-package.test.tswith the coverage listed above.Test Coverage Requirements
apps/**is outside this repo's Codecovcoverage.include(vitest.config.ts/codecov.yml'signore: ["apps/**", ...]), so this change owes no Codecov patch-coverage percentage. Aim for genuinebranch coverage of every conditional in the five functions listed above (both sides of each
?/??fallback), since a one-line regex or fallback-order mistake here is exactly the kind of thing branch
coverage catches and line coverage doesn't. Run
npx vitest run apps/loopover-ui/src/lib/mcp-package.test.tswhile iterating, andnpm run ui:testbefore opening the PR.
Expected Outcome
The version-selection logic that decides what install command and "latest" badge every visitor to the
site sees has a real regression suite, so a future change (e.g. adjusting the stable-version regex, or
changing the sort/fallback order) that accidentally started recommending a prerelease build as
"latest" would fail a test instead of shipping silently.
Links & Resources
apps/loopover-ui/src/lib/mcp-package.ts(the module to test)apps/loopover-ui/src/components/site/mcp-version-badge.tsxandapps/loopover-ui/src/components/site/npm-install.tsx(the real call sites)apps/loopover-ui/src/lib/config-generator-yaml.test.tsfor this repo's established plain-vitest,no-React pure-function test pattern