mirror of
https://github.com/morluto/rea.git
synced 2026-11-13 10:12:50 +00:00
Add caller-supplied Kuna readiness, scoped doctor support and a verified whole-program export cache. Index function byte ranges without introducing analysis-tool responses, and retain unresolved process ownership through cleanup failures. Separate retryable file cleanup from unproven process cleanup. Verified real Kuna 1.833 on Debian 12 x86-64 with coreutils, SQLite and zlib; 5,207 exported function spans, cold/warm performance, raw-export parity and lifecycle failures. Refs #1957. Co-authored-by: gensokyo-dev <342580529+gensokyo-dev@users.noreply.github.com> Co-authored-by: Kaoru0822 <208281322+kaoru0822-kitauji@users.noreply.github.com> Co-authored-by: N0zoM1z0 <161784452+N0zoM1z0@users.noreply.github.com> Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com>
78 lines
2.8 KiB
TypeScript
78 lines
2.8 KiB
TypeScript
import { chmod, mkdir, realpath, writeFile } from "node:fs/promises";
|
|
import { join } from "node:path";
|
|
|
|
import { expect, it as test } from "vitest";
|
|
|
|
import { createSystemDoctorHost } from "./doctorRuntime.js";
|
|
import { DOCTOR_PROVIDER_IDS } from "./application/DoctorProviderIds.js";
|
|
import { providerRegistrationEnvironment } from "./application/SetupRegistrationEnvironment.js";
|
|
import { createTestTempDirectory } from "../tests/fixtures/temporaryDirectory.js";
|
|
import { writeJadxJarInventory } from "../tests/fixtures/android/jadxJar.js";
|
|
|
|
const it = test.skipIf(process.platform === "win32");
|
|
|
|
it("exposes jadx through the doctor provider selector", () => {
|
|
expect(DOCTOR_PROVIDER_IDS).toContain("jadx");
|
|
});
|
|
|
|
it("carries a validated REA_JADX_MCP_JAR into the provider registration environment", async () => {
|
|
const root = await createTestTempDirectory("rea-jadx-registration-");
|
|
const jar = join(root, "jadx-headless-mcp.jar");
|
|
const javaHome = await createFakeJdk(root);
|
|
await writeJadxJarInventory(jar);
|
|
|
|
const host = createSystemDoctorHost({
|
|
REA_JADX_MCP_JAR: jar,
|
|
JAVA_HOME: javaHome,
|
|
});
|
|
const inspections = await host.providerInspections?.();
|
|
expect(inspections?.map(({ id }) => id)).toContain("jadx");
|
|
|
|
const environment = providerRegistrationEnvironment(inspections ?? []);
|
|
expect(environment).toMatchObject({
|
|
REA_JADX_MCP_JAR: await realpath(jar),
|
|
});
|
|
});
|
|
|
|
it("omits REA_JADX_MCP_JAR from the provider registration environment when it is not configured", async () => {
|
|
const host = createSystemDoctorHost({});
|
|
const inspections = await host.providerInspections?.();
|
|
|
|
const environment = providerRegistrationEnvironment(inspections ?? []);
|
|
expect(environment).not.toHaveProperty("REA_JADX_MCP_JAR");
|
|
});
|
|
|
|
it("carries a validated REA_KUNA_COMMAND into the provider registration environment", async () => {
|
|
expect(DOCTOR_PROVIDER_IDS).toContain("kuna");
|
|
const root = await createTestTempDirectory("rea-kuna-registration-");
|
|
const kuna = join(root, "kuna");
|
|
await writeFile(kuna, "#!/bin/sh\nprintf 'kuna 1.833\\n'\n", { mode: 0o700 });
|
|
|
|
const inspections = await createSystemDoctorHost({
|
|
REA_KUNA_COMMAND: kuna,
|
|
REA_KUNA_CACHE_DIR: join(root, "cache"),
|
|
}).providerInspections?.();
|
|
|
|
expect(inspections?.find(({ id }) => id === "kuna")).toMatchObject({
|
|
available: true,
|
|
providerVersion: "1.833",
|
|
});
|
|
expect(providerRegistrationEnvironment(inspections ?? [])).toMatchObject({
|
|
REA_KUNA_COMMAND: kuna,
|
|
REA_KUNA_CACHE_DIR: join(root, "cache"),
|
|
});
|
|
});
|
|
|
|
const createFakeJdk = async (root: string): Promise<string> => {
|
|
const javaHome = join(root, "fake-jdk");
|
|
const bin = join(javaHome, "bin");
|
|
const java = join(bin, "java");
|
|
await mkdir(bin, { recursive: true });
|
|
await writeFile(
|
|
java,
|
|
"#!/bin/sh\nprintf 'java.base@21\\njdk.compiler@21\\n'\n",
|
|
);
|
|
await chmod(java, 0o700);
|
|
return javaHome;
|
|
};
|