test: strengthen MCP prompt acceptance coverage

This commit is contained in:
N0zoM1z0
2026-07-13 21:21:32 +08:00
parent 24c3adb553
commit 05fb9b17c9
4 changed files with 389 additions and 18 deletions
+23 -11
View File
@@ -36,19 +36,31 @@ export const verifyPackagedPromptCatalog = async (
throw new Error("packaged MCP guided prompt rendering failed");
};
/** Verify live completion through the installed stdio MCP artifact. */
export const verifyPackagedPromptCompletion = async (client, options) => {
const result = await client.complete(
/** Verify live completion through each installed stdio target state. */
export const verifyPackagedPromptCompletion = async (
client,
options,
targetOpen,
) => {
const expected = targetOpen ? ["fixture"] : [];
const requests = [
{
ref: { type: "ref/prompt", name: "investigate_feature" },
argument: { name: "document", value: "fix" },
},
options,
);
if (
JSON.stringify(result.completion.values) !== JSON.stringify(["fixture"]) ||
result.completion.total !== 1 ||
result.completion.hasMore !== false
)
throw new Error("packaged MCP prompt completion failed");
{
ref: { type: "ref/prompt", name: "investigate_feature" },
argument: { name: "procedure", value: "fix" },
context: { arguments: { document: "fixture" } },
},
];
for (const request of requests) {
const result = await client.complete(request, options);
if (
JSON.stringify(result.completion.values) !== JSON.stringify(expected) ||
result.completion.total !== expected.length ||
result.completion.hasMore !== false
)
throw new Error("packaged MCP prompt completion lifecycle failed");
}
};
+4 -2
View File
@@ -430,6 +430,7 @@ try {
)
throw new Error("packaged MCP tool inventory diverged from contracts");
await verifyPackagedPromptCatalog(client, mcpOptions, expectedPromptNames);
await verifyPackagedPromptCompletion(client, mcpOptions, false);
const result = await client.callTool(
{ name: "current_document", arguments: {} },
mcpOptions,
@@ -442,7 +443,7 @@ try {
);
if (opened.isError === true)
throw new Error("packaged MCP could not open a binary");
await verifyPackagedPromptCompletion(client, mcpOptions);
await verifyPackagedPromptCompletion(client, mcpOptions, true);
const current = await client.callTool(
{ name: "current_document", arguments: {} },
mcpOptions,
@@ -472,6 +473,7 @@ try {
);
if (closed.isError === true)
throw new Error("packaged MCP could not close its binary");
await verifyPackagedPromptCompletion(client, mcpOptions, false);
const mcpBundlePath = join(evidenceRoot, "mcp.json");
const mcpExport = await client.callTool(
{ name: "export_evidence_bundle", arguments: { path: mcpBundlePath } },
@@ -493,7 +495,7 @@ try {
}
process.stdout.write(
`${JSON.stringify({ cli: true, analysisCli: true, artifactCli: true, evidenceCli: true, incurMcpCommand: "npx -y rea-agents mcp", doctor: "platform-appropriate", setup: supportedSetupHost ? "planned-then-idempotent" : "unsupported-host-rejected", setupPlanReadOnly: supportedSetupHost, existingHopperPreserved: supportedSetupHost, clients: supportedSetupHost ? 2 : 0, backupReadback: supportedSetupHost, failureRecovery: supportedSetupHost, skill: supportedSetupHost, mcpTools: expectedToolCount, mcpPrompts: expectedPromptNames.length, promptCompletion: true, evidenceMcp: true, targetFree: true, targetLifecycle: true })}\n`,
`${JSON.stringify({ cli: true, analysisCli: true, artifactCli: true, evidenceCli: true, incurMcpCommand: "npx -y rea-agents mcp", doctor: "platform-appropriate", setup: supportedSetupHost ? "planned-then-idempotent" : "unsupported-host-rejected", setupPlanReadOnly: supportedSetupHost, existingHopperPreserved: supportedSetupHost, clients: supportedSetupHost ? 2 : 0, backupReadback: supportedSetupHost, failureRecovery: supportedSetupHost, skill: supportedSetupHost, mcpTools: expectedToolCount, mcpPrompts: expectedPromptNames.length, promptCompletion: true, promptCompletionLifecycle: true, evidenceMcp: true, targetFree: true, targetLifecycle: true })}\n`,
);
} finally {
if (tarball) await rm(join(root, tarball), { force: true });