feat(setup): verify installed skill catalog identity
This commit is contained in:
@@ -6,7 +6,6 @@ import {
|
||||
ENHANCED_TOOL_CONTRACTS,
|
||||
OFFICIAL_TOOL_CONTRACTS,
|
||||
SESSION_TOOL_CONTRACTS,
|
||||
TOOL_CONTRACTS,
|
||||
} from "../src/contracts/toolContracts.js";
|
||||
import { NATIVE_TOOL_CONTRACTS } from "../src/contracts/nativeToolContracts.js";
|
||||
import { ARTIFACT_TOOL_CONTRACTS } from "../src/contracts/artifactToolContracts.js";
|
||||
@@ -39,30 +38,18 @@ const expectedToolCounts = [
|
||||
|
||||
const toolCountsFromReadme = (content: string, path: string): number[] => {
|
||||
const lines = content.split(/\r?\n/u);
|
||||
const headingIndex = lines.findIndex((line) =>
|
||||
new RegExp(`^## .*${String(TOOL_CONTRACTS.length)}`, "u").test(line),
|
||||
);
|
||||
if (headingIndex === -1)
|
||||
throw new Error(
|
||||
`Missing ${String(TOOL_CONTRACTS.length)}-tool heading in ${path}`,
|
||||
);
|
||||
|
||||
const counts: number[] = [];
|
||||
for (const line of lines.slice(headingIndex + 1)) {
|
||||
if (line.startsWith("## ")) break;
|
||||
if (!line.trim().startsWith("|") || /^\|\s*-/.test(line)) continue;
|
||||
const cells = line.split("|").map((cell) => cell.trim());
|
||||
const countCell = cells[2];
|
||||
if (countCell === undefined)
|
||||
throw new Error(`Malformed table row in ${path}`);
|
||||
const count = Number(countCell);
|
||||
if (!Number.isInteger(count)) {
|
||||
if (counts.length === 0) continue;
|
||||
throw new Error(`Non-numeric tool count in ${path}`);
|
||||
for (const [index, line] of lines.entries()) {
|
||||
if (!/^\|\s*-/u.test(line)) continue;
|
||||
const counts: number[] = [];
|
||||
for (const row of lines.slice(index + 1)) {
|
||||
if (!row.trim().startsWith("|")) break;
|
||||
const count = Number(row.split("|")[2]?.trim());
|
||||
if (!Number.isInteger(count)) break;
|
||||
counts.push(count);
|
||||
}
|
||||
counts.push(count);
|
||||
if (counts.length === expectedToolCounts.length) return counts;
|
||||
}
|
||||
return counts;
|
||||
throw new Error(`Missing tool-family inventory table in ${path}`);
|
||||
};
|
||||
|
||||
describe("localized README product facts", () => {
|
||||
@@ -87,7 +74,7 @@ describe("localized README product facts", () => {
|
||||
expect(content).toContain(client.displayName);
|
||||
if (path === "README_ar.md")
|
||||
expect(content).toContain("Windows غير مدعوم حاليًا");
|
||||
expect(content).toContain(`MCP_tools-${String(TOOL_CONTRACTS.length)}`);
|
||||
expect(content).toContain("MCP-tool_catalog");
|
||||
expect(toolCountsFromReadme(content, path)).toEqual(expectedToolCounts);
|
||||
},
|
||||
);
|
||||
|
||||
Reference in New Issue
Block a user