Merge remote-tracking branch 'origin/main' into feat/mcp-prompts-completion

# Conflicts:
#	scripts/verify-package.mjs
This commit is contained in:
morluto
2026-07-14 04:55:38 +08:00
197 changed files with 8459 additions and 1120 deletions
+16 -19
View File
@@ -14,19 +14,11 @@ import { promisify } from "node:util";
import { Client } from "@modelcontextprotocol/client";
import { StdioClientTransport } from "@modelcontextprotocol/client/stdio";
import { TextReader, Uint8ArrayWriter, ZipWriter } from "@zip.js/zip.js";
import { PROMPT_CONTRACTS } from "../dist/contracts/promptContracts.js";
import { TOOL_CONTRACTS } from "../dist/contracts/toolContracts.js";
import {
mcpText,
verifyPackagedPromptCatalog,
verifyPackagedPromptCompletion,
} from "./verify-package-prompts.mjs";
import * as prompts from "./verify-package-prompts.mjs";
import { verifyPackagedInvestigation } from "./verify-package-investigation.mjs";
import { verifyPackedBridge } from "./verify-packed-bridge.mjs";
const expectedToolCount = TOOL_CONTRACTS.length;
const expectedPromptNames = PROMPT_CONTRACTS.map(({ name }) => name);
// Exercise the packed artifact in isolated HOME and prefix directories so the
// verifier cannot mutate real MCP registrations or rely on checkout-only files.
const exec = promisify(execFile);
const root = process.cwd();
const workspace = await mkdtemp(join(tmpdir(), "rea-package-"));
@@ -48,6 +40,7 @@ try {
) {
throw new Error("package contained generated Python bytecode");
}
await verifyPackedBridge({ root, workspace, tarball, packedFiles });
const prefix = join(workspace, "prefix");
const home = join(workspace, "home");
const fakeBin = join(workspace, "bin");
@@ -109,6 +102,7 @@ try {
]),
REA_NPX_LOG: npxLog,
REA_EVIDENCE_ROOTS_JSON: JSON.stringify([evidenceRoot]),
REA_INVESTIGATION_INPUT_ROOTS_JSON: JSON.stringify([workspace]),
REA_REFERENCE_ROOTS_JSON: JSON.stringify([referenceRoot]),
REA_REFERENCE_SECRET_PATTERNS_JSON: JSON.stringify([".env"]),
};
@@ -129,6 +123,7 @@ try {
!help.includes("upgrade") ||
!help.includes("inventory-artifact") ||
!help.includes("extract-artifact") ||
!help.includes("investigate-versions") ||
!help.includes("import-reference-source") ||
!help.includes("compare") ||
!llms.includes("decompile") ||
@@ -163,6 +158,8 @@ try {
artifactInventory.normalized_result?.manifest?.root_format !== "zip"
)
throw new Error("packaged artifact inventory CLI failed");
// prettier-ignore
await verifyPackagedInvestigation({ cli, workspace, evidenceRoot, artifactArchive, environment });
const overview = json(
await run(cli, ["analyze", process.execPath, "--json"], environment),
);
@@ -426,11 +423,11 @@ try {
const mcpOptions = { timeout: 15_000 };
if (
(await client.listTools(undefined, mcpOptions)).tools.length !==
expectedToolCount
TOOL_CONTRACTS.length
)
throw new Error("packaged MCP tool inventory diverged from contracts");
await verifyPackagedPromptCatalog(client, mcpOptions, expectedPromptNames);
await verifyPackagedPromptCompletion(client, mcpOptions, false);
await prompts.verifyPromptCatalog(client, mcpOptions, prompts.names);
await prompts.verifyPromptCompletion(client, mcpOptions, false);
const result = await client.callTool(
{ name: "current_document", arguments: {} },
mcpOptions,
@@ -443,21 +440,21 @@ try {
);
if (opened.isError === true)
throw new Error("packaged MCP could not open a binary");
await verifyPackagedPromptCompletion(client, mcpOptions, true);
await prompts.verifyPromptCompletion(client, mcpOptions, true);
const current = await client.callTool(
{ name: "current_document", arguments: {} },
mcpOptions,
);
if (
current.isError === true ||
json(mcpText(current)).normalized_result !== "fixture"
json(prompts.mcpText(current)).normalized_result !== "fixture"
)
throw new Error("packaged MCP bridge call failed");
const batch = await client.callTool(
{ name: "batch_decompile", arguments: { addresses: ["0x1000"] } },
mcpOptions,
);
const batchResult = json(mcpText(batch)).normalized_result;
const batchResult = json(prompts.mcpText(batch)).normalized_result;
if (
batch.isError === true ||
batchResult?.total !== 1 ||
@@ -473,7 +470,7 @@ try {
);
if (closed.isError === true)
throw new Error("packaged MCP could not close its binary");
await verifyPackagedPromptCompletion(client, mcpOptions, false);
await prompts.verifyPromptCompletion(client, mcpOptions, false);
const mcpBundlePath = join(evidenceRoot, "mcp.json");
const mcpExport = await client.callTool(
{ name: "export_evidence_bundle", arguments: { path: mcpBundlePath } },
@@ -495,7 +492,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, promptCompletionLifecycle: 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: TOOL_CONTRACTS.length, mcpPrompts: prompts.names.length, promptCompletion: true, promptCompletionLifecycle: true, evidenceMcp: true, targetFree: true, targetLifecycle: true, boundedRegexBridge: true })}\n`,
);
} finally {
if (tarball) await rm(join(root, tarball), { force: true });