mirror of
https://github.com/morluto/rea.git
synced 2026-12-06 14:59:05 +00:00
* test(clients): verify native OpenCode integration against OpenCode V2 The OpenCode client lane targeted OpenCode V1 (opencode-ai@1.18.35) and could not pass against OpenCode V2. The V2 skill tool names its argument `id`, so the lane's `{ name: ... }` call was rejected with "id: Missing key" and the personal skill never loaded. Bring the lane to OpenCode V2: - Call the skill tool with `id` under V2 and keep `name` for V1. - Register REA in the native `mcp.servers` table and read additional skill sources from the `skills` array; grant tool access with a `permissions` ruleset. The V1 dialect remains selectable with `REA_VERIFY_OPENCODE_DIALECT=v1`. - OpenCode V2 groups MCP tools behind its Code Mode tool by default, so the lane sets the documented `codemode: false` server option to observe the forwarded catalog as direct function tools. REA's refresh preserves that client-owned option, which the lane now covers. - Start a private server under V2. The shared background service keeps the environment it started with and would read the caller's own configuration instead of the lane's isolated one. - Isolate the home for both platforms. The lane set only USERPROFILE, so a POSIX run resolved the caller's real home for the shared skill directory. - Take the expected catalog from the runtime under test, so `REA_VERIFY_RUNTIME_ROOT` can point at an installed package whose catalog differs from this checkout. - Record the dialect, plugin-isolation mechanism and tool surface in the receipt. OpenCode V2 dropped OPENCODE_PURE, so the V1 isolation claim no longer described what ran. The lane no longer refuses Windows, so the OpenCode integration can be verified on a native Windows host. * fix(clients): isolate OpenCode verifier config and coverage claims Clear inherited OPENCODE_CONFIG and OPENCODE_CONFIG_CONTENT so the lab cannot load the caller's configuration layers. Record V2 as verified only on native Windows and leave POSIX V2 explicitly unverified. * fix(clients): pin OpenCode verifier to a full REA catalog Clear inherited REA_MCP_TOOL_FAMILIES and set REA_MCP_TOOL_CATALOG_PROFILE=full so setup and the MCP child always advertise the complete catalog the fixture asserts. * fix(ci): pin Native MCP OpenCode checks to @opencode/cli@2.2.7 The verifier defaults to the OpenCode V2 dialect, but the Native MCP registration workflow still installed opencode-ai@1.19.6 without selecting v1. Point the matrix at the published V2 CLI that supports the V2 config and --standalone. * fix(clients): harden OpenCode V2 verifier modes and launch seeds Keep Code Mode enabled for scoped-chat and assert the paginated catalog search, clear inherited REA MCP capacity/schema settings that can reject fixture calls, and accept Aube-managed shim launchers alongside the raw Node/script/mcp shape. * fix(clients): only require Code Mode catalog search for OpenCode V2 * fix(clients): clear OpenCode verifier ambient budget and Windows env aliases Unset inherited REA_AGENT_RESULT_BUDGET_BYTES so the fixture keeps complete Evidence, and delete cleared OpenCode/REA launch seeds case-insensitively before spawn so mixed-case Windows aliases cannot survive. * fix(clients): require Windows packaged OpenCode runtime and isolate V2 ancestors Document that Windows call verification needs REA_VERIFY_RUNTIME_ROOT with a matching packaged runtime, and refuse OpenCode V2 lab runs when an ancestor project configuration file would join the private server. * fix(clients): qualify POSIX OpenCode V2 coverage and dialect Windows hint Limit checked-in POSIX V2 claims to scoped-chat catalog search and point Windows preflight recovery at the selected OpenCode package major. * fix(clients): match OpenCode runtime contracts and clear registration seeds Reject a REA_VERIFY_RUNTIME_ROOT whose package version or tool catalog differs from this checkout, and clear every selected registration setting from SetupRegistrationEnvironment instead of a hand-maintained MCP list. * fix(verification): bind OpenCode fixtures to selected runtime * fix(verification): refuse discovered OpenCode plugin sources * test(verification): reject plugins before starting OpenCode * test(ci): exercise packaged OpenCode on Windows * fix(verification): type the selected-runtime fixture reader * chore(ci): use pinned npm for Windows client proof * docs(verification): distinguish Windows runner isolation * test(verification): keep compiled fixtures in the built test lane * test(verification): type catalog fixtures without generated output * fix(ci): classify automated OpenCode verification
176 lines
5.9 KiB
TypeScript
176 lines
5.9 KiB
TypeScript
import type { DoctorProviderInspection } from "../ports/DoctorProviderInspection.js";
|
|
import { compareUnicodeCodePoints } from "../domain/unicodeCodePointOrder.js";
|
|
import { absoluteCallerSelection } from "../filesystem/callerPath.js";
|
|
|
|
const KUNA_SPEC_REGISTRATION_SETTINGS = ["KUNA_SPECS", "SLEIGHHOME"] as const;
|
|
|
|
/** A saved spec root must not depend on the client's later working directory. */
|
|
const registeredSettingValue = (key: string, value: string): string =>
|
|
KUNA_SPEC_REGISTRATION_SETTINGS.some((spec) => spec === key)
|
|
? absoluteCallerSelection(value)
|
|
: value;
|
|
|
|
/** Explicit registration seeds setup may copy from the launch environment. */
|
|
export const SELECTED_REGISTRATION_SETTINGS = [
|
|
"GHIDRA_INSTALL_DIR",
|
|
"GHIDRA_HEADLESS_MAXMEM",
|
|
"GHIDRA_MAXMEM",
|
|
"JAVA_HOME",
|
|
"HOPPER_LAUNCHER_PATH",
|
|
"HOPPER_LOADER_ARGS_JSON",
|
|
"REA_ILSPY_CMD_PATH",
|
|
"REA_ADB_PATH",
|
|
"REA_APKTOOL_COMMAND",
|
|
"REA_TSHARK_COMMAND",
|
|
"REA_CAPINFOS_COMMAND",
|
|
"REA_TSHARK_PRLIMIT_COMMAND",
|
|
"REA_OBJDUMP_COMMAND",
|
|
"REA_YARA_COMMAND",
|
|
"REA_GDB_COMMAND",
|
|
"REA_RIZIN_COMMAND",
|
|
"REA_CUTTER_BRIDGE_DIR",
|
|
"REA_WABT_BIN_DIRECTORY",
|
|
"REA_WAKARU_COMMAND",
|
|
"REA_JAVASCRIPT_PRLIMIT_COMMAND",
|
|
"REA_BINWALK_COMMAND",
|
|
"REA_UNBLOB_COMMAND",
|
|
"REA_FIRMWARE_PRLIMIT_COMMAND",
|
|
"REA_EVM_PRLIMIT_COMMAND",
|
|
"REA_SIGROK_COMMAND",
|
|
"REA_SIGROK_PRLIMIT_COMMAND",
|
|
"REA_MITMDUMP_COMMAND",
|
|
"REA_BROWSER_EXECUTABLE",
|
|
"REA_BROWSER_NO_SANDBOX",
|
|
"REA_PWNTOOLS_PYTHON",
|
|
"REA_PWNTOOLS_MAX_INPUT_BYTES",
|
|
"REA_PRODUCER_OUTPUT_BYTES",
|
|
"REA_PWNDBG_GDB",
|
|
"REA_PWNDBG_GDBINIT",
|
|
"REA_PWNDBG_VENV_PATH",
|
|
"REA_DARWIN_SWIFTC_PATH",
|
|
"REA_DARWIN_MODULE_CACHE_PATH",
|
|
"SDKROOT",
|
|
"REA_SWIFTC_COMPILE_TIMEOUT_MS",
|
|
"REA_LOG_LEVEL",
|
|
"REA_REFERENCE_SECRET_PATTERNS_JSON",
|
|
"REA_IDA_MCP_CONFIG",
|
|
"REA_JADX_MCP_JAR",
|
|
"REA_JADX_HEAP_MIB",
|
|
"REA_JADX_ACTIVE_PROCESSOR_COUNT",
|
|
"REA_JADX_OPERATION_TIMEOUT_MS",
|
|
"REA_KUNA_COMMAND",
|
|
"REA_KUNA_CACHE_DIR",
|
|
"REA_KUNA_CACHE_MAX_BYTES",
|
|
"REA_KUNA_PROJECT_TIMEOUT_MS",
|
|
"REA_KUNA_TIMEOUT_MS",
|
|
"REA_KUNA_JOBS",
|
|
"KUNA_SPECS",
|
|
"SLEIGHHOME",
|
|
"REA_ANALYSIS_PROVIDER",
|
|
"REA_ASAR_MAX_HEADER_BYTES",
|
|
"REA_ASAR_MAX_LISTING_BYTES",
|
|
"REA_GHIDRA_VALUE_FLOW_MAX_OPERATIONS",
|
|
"REA_GHIDRA_VALUE_FLOW_MAX_INPUTS_PER_OPERATION",
|
|
"REA_GHIDRA_VALUE_FLOW_MAX_EDGES",
|
|
"REA_GHIDRA_DECOMPILE_MAX_PAYLOAD_MIB",
|
|
"REA_BRIDGE_MAX_REQUEST_BYTES",
|
|
"REA_BRIDGE_MAX_REPLY_BYTES",
|
|
"REA_CAPTURE_DECODER_OLD_GENERATION_MIB",
|
|
"REA_CAPTURE_PACKET_JSON_EXPANSION_BYTES",
|
|
"REA_GHIDRA_DECOMPILE_TIMEOUT_SECONDS",
|
|
"REA_GHIDRA_STARTUP_TIMEOUT_MS",
|
|
"REA_GHIDRA_CANCEL_GRACE_MS",
|
|
"REA_GHIDRA_LANGUAGE_ID",
|
|
"REA_GHIDRA_COMPILER_SPEC_ID",
|
|
"REA_GHIDRA_DISABLED_ANALYZERS",
|
|
"REA_GHIDRA_SEED_FILE",
|
|
"REA_GHIDRA_PROJECT_PATH",
|
|
"REA_GHIDRA_CHECKPOINT_DIR",
|
|
"REA_GHIDRA_CHECKPOINT_SAVE_WAIT_MS",
|
|
"REA_GHIDRA_PROGRAM_NAME",
|
|
"REA_GHIDRA_NATIVEAOT_JAR",
|
|
"REA_HOPPER_CALLER_SCAN_BUDGET_MS",
|
|
"REA_HOPPER_STARTUP_TIMEOUT_MS",
|
|
"REA_JEB_MCP_URL",
|
|
"REA_JEB_MCP_TIMEOUT_MS",
|
|
"REA_JAVASCRIPT_MEMBER_MUTATION_ALIAS_STATES",
|
|
"REA_MCP_INPUT_SCHEMA_PROFILE",
|
|
"REA_MCP_TOOL_FAMILIES",
|
|
"REA_MCP_OUTPUT_SCHEMA_PROFILE",
|
|
"REA_MCP_TOOL_CATALOG_PROFILE",
|
|
"REA_MCP_MAX_RESPONSE_BYTES",
|
|
"REA_MCP_MAX_INPUT_ELEMENTS",
|
|
"REA_NATIVE_MATCHING_REPRESENTATION_BYTES",
|
|
"REA_REGEX_MATCHING_DEADLINE_MS",
|
|
"REA_REGEX_WORKER_HEAP_REQUEST_MIB",
|
|
"REA_WINDOWS_CHANGE_TIME_DRIFT_MS",
|
|
"REA_WINDOWS_CHANGE_TIME_SETTLE_MAX_POLLS",
|
|
"REA_WINDOWS_CHANGE_TIME_SETTLE_POLL_MS",
|
|
"REA_MCP_INITIALIZE_BUDGET_MS",
|
|
"REA_MCP_TOOLS_LIST_BUDGET_MS",
|
|
"REA_MCP_TOOLS_LIST_PAGE_BYTES",
|
|
"REA_MCP_FIRST_CATALOG_BUDGET_MS",
|
|
"REA_MCP_DOCTOR_DEADLINE_MS",
|
|
] as const;
|
|
|
|
/**
|
|
* Settings setup can add to a registration from provider discovery when the
|
|
* caller did not select them: Hopper's launcher (doctor's Hopper search) and
|
|
* Ghidra's installation and Java (Ghidra's inspection). Other providers'
|
|
* registration settings echo explicit selections. Update maintenance does not
|
|
* run that discovery, so it cannot tell what setup would write for these.
|
|
*/
|
|
export const DISCOVERED_REGISTRATION_SETTINGS = [
|
|
"HOPPER_LAUNCHER_PATH",
|
|
"GHIDRA_INSTALL_DIR",
|
|
"JAVA_HOME",
|
|
] as const;
|
|
|
|
/** Explicit selections override discovered defaults even when a provider is unavailable.
|
|
* This is a registration policy, not a prefix match against the ambient environment.
|
|
*/
|
|
export const explicitSetupRegistrationEnvironment = (
|
|
environment: Readonly<Record<string, string | undefined>>,
|
|
): Readonly<Record<string, string>> =>
|
|
Object.fromEntries(
|
|
SELECTED_REGISTRATION_SETTINGS.flatMap((key) => {
|
|
const value = environment[key];
|
|
return value === undefined
|
|
? []
|
|
: [[key, registeredSettingValue(key, value)]];
|
|
}),
|
|
);
|
|
|
|
/** Saved values stay in the settings file and must never be copied to a client. */
|
|
export const copyableProviderRegistrationSettings = ({
|
|
registrationEnvironment,
|
|
providerSettings,
|
|
}: DoctorProviderInspection): readonly [string, string][] =>
|
|
Object.entries(registrationEnvironment).filter(
|
|
([key]) => providerSettings?.[key]?.source !== "config",
|
|
);
|
|
|
|
/** Discovered provider defaults; explicit selections are applied separately. */
|
|
export const providerRegistrationEnvironment = (
|
|
inspections: readonly DoctorProviderInspection[],
|
|
): Readonly<Record<string, string>> =>
|
|
Object.fromEntries(
|
|
inspections
|
|
.flatMap(copyableProviderRegistrationSettings)
|
|
.sort(([left], [right]) => compareUnicodeCodePoints(left, right)),
|
|
);
|
|
|
|
/** Spell selected settings as setup records them: an explicit selection wins. */
|
|
export const registrationSpelledSettings = (
|
|
settings: Readonly<Record<string, string>>,
|
|
environment: Readonly<Record<string, string | undefined>>,
|
|
): Readonly<Record<string, string>> => {
|
|
const explicit = explicitSetupRegistrationEnvironment(environment);
|
|
return Object.fromEntries(
|
|
Object.entries(settings).map(([key, value]) => [
|
|
key,
|
|
explicit[key] ?? value,
|
|
]),
|
|
);
|
|
};
|