fix(ci): share provider workflows to restore static gates

This commit is contained in:
morluto
2026-10-10 23:15:02 +08:00
parent bddddccdee
commit a97bd5ed29
22 changed files with 290 additions and 304 deletions
+1 -20
View File
@@ -1,25 +1,6 @@
import { expect, it } from "vitest";
import { createCli } from "../../../src/cli.js";
const serve = async (
argv: readonly string[],
environment: Readonly<Record<string, string | undefined>> = {},
): Promise<{ readonly stdout: string; readonly exitCode: number }> => {
const cli = createCli(environment);
let stdout = "";
let exitCode = 0;
await cli.serve([...argv], {
env: {},
exit: (code) => {
exitCode = code;
},
stdout: (text) => {
stdout += text;
},
});
return { stdout, exitCode };
};
import { serveCli as serve } from "./cliServeHarness.js";
it.each([
["inspect-adb-client"],
+1 -20
View File
@@ -1,25 +1,6 @@
import { expect, it } from "vitest";
import { createCli } from "../../../src/cli.js";
const serve = async (
argv: readonly string[],
environment: Readonly<Record<string, string | undefined>> = {},
): Promise<{ readonly stdout: string; readonly exitCode: number }> => {
const cli = createCli(environment);
let stdout = "";
let exitCode = 0;
await cli.serve([...argv], {
env: {},
exit: (code) => {
exitCode = code;
},
stdout: (text) => {
stdout += text;
},
});
return { stdout, exitCode };
};
import { serveCli as serve } from "./cliServeHarness.js";
it.each(["inspect-apktool-client", "decode-android-resources"])(
"%s advertises a schema through the public CLI",
+27
View File
@@ -0,0 +1,27 @@
import { createCli } from "../../../src/cli.js";
/** Captured CLI invocation for boundary tests. */
export interface ServedCli {
readonly stdout: string;
readonly exitCode: number;
}
/** Serve one CLI invocation with captured output and exit code. */
export const serveCli = async (
argv: readonly string[],
environment: Readonly<Record<string, string | undefined>> = {},
): Promise<ServedCli> => {
const cli = createCli(environment);
let stdout = "";
let exitCode = 0;
await cli.serve([...argv], {
env: {},
exit: (code) => {
exitCode = code;
},
stdout: (text) => {
stdout += text;
},
});
return { stdout, exitCode };
};
+7 -18
View File
@@ -1,26 +1,15 @@
import { expect, it } from "vitest";
import { createCli } from "../../../src/cli.js";
import { serveCli } from "./cliServeHarness.js";
const jebEnvironment = {
REA_JEB_MCP_URL: "http://127.0.0.1:1/mcp",
};
const serve = async (
argv: readonly string[],
): Promise<{ readonly stdout: string; readonly exitCode: number }> => {
const cli = createCli({
REA_JEB_MCP_URL: "http://127.0.0.1:1/mcp",
});
let stdout = "";
let exitCode = 0;
await cli.serve([...argv], {
env: {},
exit: (code) => {
exitCode = code;
},
stdout: (text) => {
stdout += text;
},
});
return { stdout, exitCode };
};
): Promise<{ readonly stdout: string; readonly exitCode: number }> =>
serveCli(argv, jebEnvironment);
it.each([
["inspect-jeb-client"],
+2 -18
View File
@@ -1,14 +1,13 @@
import { Client, InMemoryTransport } from "@modelcontextprotocol/client";
import { Ajv2020 } from "ajv/dist/2020.js";
import { expect, it, onTestFinished } from "vitest";
import type { AdbDeviceAnalysisPort } from "../../../src/application/adb/AdbDeviceAnalysisPort.js";
import { createAnalysisExecution } from "../../../src/application/AnalysisProvider.js";
import { toolContract } from "../../../src/contracts/toolContracts.js";
import { parseEvidence } from "../../../src/domain/evidence.js";
import { ok } from "../../../src/domain/result.js";
import { createServer } from "../../../src/server/createServer.js";
import { createTestBinarySession } from "../../fixtures/binarySession.js";
import { assertAdvertisedMcpContracts } from "./mcpContractHarness.js";
const identity = { id: "adb", name: "Android Debug Bridge", version: null };
@@ -320,22 +319,7 @@ it("advertises exact valid ADB schemas and records inline evidence through MCP",
] as const;
for (const name of operationNames) expect(names, name).toContain(name);
const ajv = new Ajv2020({ strict: false, allErrors: true });
for (const name of operationNames) {
const contract = toolContract(name);
const listed = tools.find((tool) => tool.name === name);
expect(listed, name).toBeTruthy();
if (listed?.inputSchema === undefined) continue;
// The server may present a compacted form of the contract schema; what
// must hold is that the advertised schema compiles and accepts the
// contract's own examples, and rejects unknown input.
const validate = ajv.compile(
JSON.parse(JSON.stringify(listed.inputSchema)),
);
for (const example of contract.examples)
expect(validate(example.input), `${name} example`).toBe(true);
expect(validate({ unknown_argument: true }), `${name} rejects`).toBe(false);
}
assertAdvertisedMcpContracts(operationNames, tools);
const pulled = await client.callTool({
name: "pull_adb_package",
+2 -15
View File
@@ -1,14 +1,13 @@
import { Client, InMemoryTransport } from "@modelcontextprotocol/client";
import { Ajv2020 } from "ajv/dist/2020.js";
import { expect, it, onTestFinished } from "vitest";
import type { ApktoolResourceAnalysisPort } from "../../../src/application/apktool/ApktoolResourceAnalysisPort.js";
import { createAnalysisExecution } from "../../../src/application/AnalysisProvider.js";
import { toolContract } from "../../../src/contracts/toolContracts.js";
import { parseEvidence } from "../../../src/domain/evidence.js";
import { ok } from "../../../src/domain/result.js";
import { createServer } from "../../../src/server/createServer.js";
import { createTestBinarySession } from "../../fixtures/binarySession.js";
import { assertAdvertisedMcpContracts } from "./mcpContractHarness.js";
const identity = { id: "apktool", name: "Apktool", version: "2.7.0-dirty" };
@@ -77,19 +76,7 @@ it("advertises exact valid Apktool schemas and records inline evidence through M
] as const;
for (const name of operationNames) expect(names, name).toContain(name);
const ajv = new Ajv2020({ strict: false, allErrors: true });
for (const name of operationNames) {
const contract = toolContract(name);
const listed = tools.find((tool) => tool.name === name);
expect(listed, name).toBeTruthy();
if (listed?.inputSchema === undefined) continue;
const validate = ajv.compile(
JSON.parse(JSON.stringify(listed.inputSchema)),
);
for (const example of contract.examples)
expect(validate(example.input), `${name} example`).toBe(true);
expect(validate({ unknown_argument: true }), `${name} rejects`).toBe(false);
}
assertAdvertisedMcpContracts(operationNames, tools);
const decoded = await client.callTool({
name: "decode_android_resources",
+39
View File
@@ -0,0 +1,39 @@
import { Ajv2020 } from "ajv/dist/2020.js";
import { expect } from "vitest";
import {
TOOL_CONTRACTS,
toolContract,
} from "../../../src/contracts/toolContracts.js";
type ToolName = (typeof TOOL_CONTRACTS)[number]["name"];
/** Advertised tool listing shape needed for contract validation. */
export interface AdvertisedMcpTool {
readonly name: string;
readonly inputSchema?: unknown;
}
/**
* Assert every named operation is advertised and its input schema compiles,
* accepts the contract's own examples, and rejects unknown input. The server
* may present a compacted form of the contract schema.
*/
export const assertAdvertisedMcpContracts = (
operationNames: readonly ToolName[],
tools: readonly AdvertisedMcpTool[],
): void => {
const ajv = new Ajv2020({ strict: false, allErrors: true });
for (const name of operationNames) {
const contract = toolContract(name);
const listed = tools.find((tool) => tool.name === name);
expect(listed, name).toBeTruthy();
if (listed?.inputSchema === undefined) continue;
const validate = ajv.compile(
JSON.parse(JSON.stringify(listed.inputSchema)),
);
for (const example of contract.examples)
expect(validate(example.input), `${name} example`).toBe(true);
expect(validate({ unknown_argument: true }), `${name} rejects`).toBe(false);
}
};