Skip to content

armgit / rea

Public Imported from GitHub
0

Reverse engineer anything with agents, from app behavior down to native binaries.

test(mcp): ready providers before live prompt completion checks (#2137)

Kaoru0822621cee192d58
diff --git a/scripts/verify-package-mcp.mjs b/scripts/verify-package-mcp.mjs
index 0d03abab1..5f43bf9b2 100644
--- a/scripts/verify-package-mcp.mjs
+++ b/scripts/verify-package-mcp.mjs
@@ -121,11 +121,8 @@ const verifyMcpNonLinuxCurrentDocument = async (
const verifyMcpBinaryLifecycle = async (client, mcpOptions) => {
await verifyMcpOpenAndBind(client, mcpOptions);
- await prompts.verifyPromptCompletion(
- client,
- mcpOptions,
- process.platform !== "linux",
- );
+ // Completion never starts a provider; only an ordinary operation readies it.
+ await prompts.verifyPromptCompletion(client, mcpOptions, false);
if (process.platform === "linux") {
await verifyMcpLinuxToolAvailability(client, mcpOptions);
} else {
@@ -133,6 +130,7 @@ const verifyMcpBinaryLifecycle = async (client, mcpOptions) => {
{ name: "current_document", arguments: {} },
mcpOptions,
);
+ await prompts.verifyPromptCompletion(client, mcpOptions, true);
await verifyMcpNonLinuxCurrentDocument(client, mcpOptions, current);
}
const closed = await client.callTool(
diff --git a/tests/boundary/mcp/promptCompletion.test.ts b/tests/boundary/mcp/promptCompletion.test.ts
index d74deb86f..f09725e12 100644
--- a/tests/boundary/mcp/promptCompletion.test.ts
+++ b/tests/boundary/mcp/promptCompletion.test.ts
@@ -50,6 +50,9 @@ describe("guided prompt completion from live analysis", () => {
expect((await session.open(target)).ok).toBe(true);
const completion = createPromptCompletionSource(session, session);
+ // Completion never starts a provider; an ordinary operation readies it.
+ expect(await completion.complete("document", "app")).toEqual([]);
+ expect((await session.execute("list_documents", {})).ok).toBe(true);
expect(await completion.complete("document", "app")).toEqual([
"App",
"AppTests",
@@ -269,8 +272,8 @@ const fixtureEnvironment = {
const client = (
requests: Array<Readonly<Record<string, unknown>>>,
-): AnalysisClient => ({
- execute(operation, parameters) {
+): AnalysisClient => {
+ const execute: AnalysisClient["execute"] = (operation, parameters) => {
if (operation === "list_documents")
return Promise.resolve(observed(["AppTests", "App", "App"]));
if (operation === "list_procedures") {
@@ -285,6 +288,11 @@ const client = (
);
}
return Promise.resolve(observed(null));
- },
- close: () => Promise.resolve(resultOk(null)),
-});
+ };
+ // An in-process fixture client is ready as soon as the session opens.
+ return {
+ execute,
+ executeIfReady: execute,
+ close: () => Promise.resolve(resultOk(null)),
+ };
+};