mirror of
https://github.com/morluto/rea.git
synced 2026-12-04 05:51:06 +00:00
* feat(setup): register Mistral Vibe CLI client * fix(setup): preserve inline Vibe entry order and reject non-boolean enable_mcp on read * fix(setup): report duplicate Vibe registrations in doctor and preserve separated subtables * docs(setup): record the Mistral Vibe 3.2.0 registration check Mistral Vibe 3.2.0 on Linux loaded the setup registration through its configuration schema and discovered REA's tools over stdio. After its own `vibe mcp add` rewrote the file, setup made no change and uninstall removed only the REA entry. Co-Authored-By: gensokyo-dev <342580529+gensokyo-dev@users.noreply.github.com> --------- Co-authored-by: gensokyo-dev <gensokyo-dev@users.noreply.github.com> Co-authored-by: gensokyo-dev <342580529+gensokyo-dev@users.noreply.github.com>
263 lines
7.6 KiB
TypeScript
263 lines
7.6 KiB
TypeScript
import { access, mkdir, readFile, writeFile } from "node:fs/promises";
|
|
import { join } from "node:path";
|
|
import { parse as parseToml } from "smol-toml";
|
|
import { expect } from "vitest";
|
|
|
|
import { createTestTempDirectory } from "../../fixtures/temporaryDirectory.js";
|
|
import {
|
|
cliTest,
|
|
type CliResult,
|
|
type TestCli,
|
|
} from "../../support/cli/cliFixture.js";
|
|
|
|
const vibeEnvironment = (
|
|
home: string,
|
|
extra: Readonly<Record<string, string>> = {},
|
|
) => ({
|
|
HOME: home,
|
|
USERPROFILE: home,
|
|
HOPPER_LAUNCHER_PATH: join(home, "missing-hopper"),
|
|
GHIDRA_INSTALL_DIR: join(home, "missing-ghidra"),
|
|
JAVA_HOME: join(home, "missing-java"),
|
|
...extra,
|
|
});
|
|
|
|
const setupVibe = (
|
|
cli: TestCli,
|
|
home: string,
|
|
extraArgs: readonly string[] = [],
|
|
extraEnv: Readonly<Record<string, string>> = {},
|
|
): Promise<CliResult> =>
|
|
cli.run({
|
|
arguments: [
|
|
"setup",
|
|
"--client",
|
|
"vibe",
|
|
"--skill=false",
|
|
"--yes",
|
|
"--json",
|
|
...extraArgs,
|
|
],
|
|
cwd: home,
|
|
environment: vibeEnvironment(home, extraEnv),
|
|
});
|
|
|
|
cliTest(
|
|
"previews, registers, re-runs idempotently, reports aligned in doctor, and uninstalls Vibe in a disposable profile",
|
|
async ({ cli }) => {
|
|
const home = await createTestTempDirectory("rea-vibe-cli-");
|
|
const vibeHome = join(home, "disposable-vibe");
|
|
const config = join(vibeHome, "config.toml");
|
|
const original = [
|
|
"# Disposable Vibe profile",
|
|
'active_model = "devstral-2"',
|
|
"",
|
|
"[[mcp_servers]]",
|
|
'name = "fetch_server"',
|
|
'transport = "stdio"',
|
|
'command = "uvx"',
|
|
'args = ["mcp-server-fetch"]',
|
|
"",
|
|
].join("\n");
|
|
await mkdir(vibeHome, { recursive: true });
|
|
await writeFile(config, original, "utf8");
|
|
|
|
const env = { VIBE_HOME: vibeHome };
|
|
|
|
// Preview plan with --dry-run does not modify config.toml
|
|
const dryRun = await cli.run({
|
|
arguments: [
|
|
"setup",
|
|
"--client",
|
|
"vibe",
|
|
"--skill=false",
|
|
"--dry-run",
|
|
"--json",
|
|
],
|
|
cwd: home,
|
|
environment: vibeEnvironment(home, env),
|
|
});
|
|
expect(dryRun.exitCode, dryRun.stdout).toBe(0);
|
|
expect(dryRun.json).toMatchObject({
|
|
status: "planned",
|
|
plannedActions: [
|
|
expect.objectContaining({
|
|
id: "configure_client:vibe",
|
|
target: config,
|
|
}),
|
|
],
|
|
});
|
|
expect(await readFile(config, "utf8")).toBe(original);
|
|
|
|
// Apply setup
|
|
const first = await setupVibe(cli, home, [], env);
|
|
expect(first.exitCode, first.stdout).toBe(0);
|
|
const configured = await readFile(config, "utf8");
|
|
expect(configured).toContain("# Disposable Vibe profile");
|
|
expect(await readFile(`${config}.rea.backup`, "utf8")).toBe(original);
|
|
expect(parseToml(configured)).toMatchObject({
|
|
active_model: "devstral-2",
|
|
mcp_servers: [
|
|
{
|
|
name: "fetch_server",
|
|
transport: "stdio",
|
|
command: "uvx",
|
|
args: ["mcp-server-fetch"],
|
|
},
|
|
{
|
|
name: "rea",
|
|
transport: "stdio",
|
|
args: expect.arrayContaining(["mcp"]),
|
|
},
|
|
],
|
|
});
|
|
|
|
// Re-run setup keeps a single REA entry and identical bytes
|
|
const second = await setupVibe(cli, home, [], env);
|
|
expect(second.exitCode, second.stdout).toBe(0);
|
|
expect(await readFile(config, "utf8")).toBe(configured);
|
|
|
|
// Doctor reports aligned & owned
|
|
const doctor = await cli.run({
|
|
arguments: ["doctor", "--client", "vibe", "--json"],
|
|
cwd: home,
|
|
environment: vibeEnvironment(home, env),
|
|
});
|
|
expect(doctor.json).toMatchObject({
|
|
identity: {
|
|
registrations: [
|
|
expect.objectContaining({
|
|
client: "vibe",
|
|
config_path: config,
|
|
state: "aligned",
|
|
command_identity: "owned",
|
|
}),
|
|
],
|
|
},
|
|
});
|
|
|
|
// Uninstall removes only REA and preserves sibling server + unrelated TOML
|
|
const uninstall = await cli.run({
|
|
arguments: ["uninstall", "--json"],
|
|
cwd: home,
|
|
environment: vibeEnvironment(home, env),
|
|
});
|
|
expect(uninstall.exitCode, uninstall.stdout).toBe(0);
|
|
const uninstallReport = uninstall.json as {
|
|
items: { name: string; status: string }[];
|
|
};
|
|
expect(
|
|
uninstallReport.items.find(({ name }) => name === "vibe")?.status,
|
|
).toBe("removed");
|
|
expect(parseToml(await readFile(config, "utf8"))).toEqual(
|
|
parseToml(original),
|
|
);
|
|
},
|
|
);
|
|
|
|
cliTest(
|
|
"refuses a user-owned rea collision and a malformed Vibe config.toml",
|
|
async ({ cli }) => {
|
|
const home = await createTestTempDirectory("rea-vibe-cli-collision-");
|
|
const vibeHome = join(home, ".vibe");
|
|
const config = join(vibeHome, "config.toml");
|
|
await mkdir(vibeHome, { recursive: true });
|
|
|
|
const foreign = [
|
|
"[[mcp_servers]]",
|
|
'name = "rea"',
|
|
'transport = "stdio"',
|
|
'command = "custom-rea"',
|
|
'args = ["serve"]',
|
|
"",
|
|
].join("\n");
|
|
await writeFile(config, foreign, "utf8");
|
|
|
|
const collision = await setupVibe(cli, home);
|
|
expect(collision.exitCode).toBe(1);
|
|
expect(collision.json).toMatchObject({
|
|
status: "needs_human",
|
|
remediation: expect.stringContaining("foreign ownership"),
|
|
});
|
|
expect(await readFile(config, "utf8")).toBe(foreign);
|
|
await expect(access(`${config}.rea.backup`)).rejects.toMatchObject({
|
|
code: "ENOENT",
|
|
});
|
|
|
|
const malformed = '[[mcp_servers]\nname = "rea"\n';
|
|
await writeFile(config, malformed, "utf8");
|
|
const invalid = await setupVibe(cli, home);
|
|
expect(invalid.exitCode).toBe(1);
|
|
expect(await readFile(config, "utf8")).toBe(malformed);
|
|
},
|
|
);
|
|
|
|
cliTest(
|
|
"blocks Vibe setup and explains unavailability in doctor when enable_mcp = false",
|
|
async ({ cli }) => {
|
|
const home = await createTestTempDirectory("rea-vibe-cli-policy-");
|
|
const vibeHome = join(home, "policy-profile");
|
|
const config = join(vibeHome, "config.toml");
|
|
const env = { VIBE_HOME: vibeHome };
|
|
const policy = 'enable_mcp = false\nactive_model = "devstral-2"\n';
|
|
await mkdir(vibeHome, { recursive: true });
|
|
await writeFile(config, policy, "utf8");
|
|
|
|
const setupResult = await setupVibe(cli, home, [], env);
|
|
expect(setupResult.exitCode).toBe(1);
|
|
expect(setupResult.json).toMatchObject({
|
|
status: "needs_human",
|
|
remediation: expect.stringContaining("enable_mcp = false"),
|
|
});
|
|
expect(await readFile(config, "utf8")).toBe(policy);
|
|
|
|
const doctor = await cli.run({
|
|
arguments: ["doctor", "--client", "vibe", "--json"],
|
|
cwd: home,
|
|
environment: vibeEnvironment(home, env),
|
|
});
|
|
expect(doctor.json).toMatchObject({
|
|
identity: {
|
|
registrations: [
|
|
expect.objectContaining({
|
|
client: "vibe",
|
|
config_path: config,
|
|
state: "manual",
|
|
remediation: expect.stringContaining("enable_mcp = false"),
|
|
}),
|
|
],
|
|
},
|
|
});
|
|
},
|
|
);
|
|
|
|
cliTest(
|
|
"resolves the Vibe skill client to the shared ~/.agents/skills directory",
|
|
async ({ cli }) => {
|
|
const home = await createTestTempDirectory("rea-vibe-cli-skill-");
|
|
const result = await cli.run({
|
|
arguments: [
|
|
"setup",
|
|
"--skill-client",
|
|
"vibe",
|
|
"--skill",
|
|
"--dry-run",
|
|
"--json",
|
|
],
|
|
cwd: home,
|
|
environment: vibeEnvironment(home),
|
|
});
|
|
expect(result.exitCode, result.stdout).toBe(0);
|
|
const plan = result.json as {
|
|
plannedActions: { id: string; target: string }[];
|
|
};
|
|
const skill = plan.plannedActions.filter(
|
|
({ id }) => id === "install_skill",
|
|
);
|
|
expect(skill).toHaveLength(1);
|
|
expect(skill[0]!.target).toBe(
|
|
join(home, ".agents", "skills", "reverse-engineer-anything"),
|
|
);
|
|
},
|
|
);
|