feat: add Hermes as a supported MCP client (#1403)
* feat: add Hermes as a supported MCP client Hermes Agent reads stdio MCP servers from `mcp_servers.<name>` in `config.yaml`. REA had no Hermes client, so setup could not register it and Hermes users had to wire the server up by hand. - SupportedClients: add the `hermes` format and client definition, resolving the config path from HERMES_HOME, else the platform default that Hermes's own resolver uses (LOCALAPPDATA/hermes on Windows, ~/.hermes elsewhere), including HERMES_DATA_DIR_SUFFIX. - ClientConfigurationDocument: parse and serialize Hermes YAML, upserting the rea entry into the parsed document so user comments and unrelated settings are preserved; emit `enabled: true` since Hermes connects entries unless disabled. - ClientRegistrationStatus: forward the Hermes location variables so status checks resolve the same path as setup. - Tests: cover path resolution on both platforms and the register/read/uninstall round trip, and clear the Hermes location variables between tests. - delilah 🌸 * docs: document the Hermes client and its config path - delilah 🌸 * refactor(setup): resolve skill destinations per client * fix(setup): install Hermes skills in the active profile * fix(setup): identify each client skill action uniquely --------- Co-authored-by: morluto <76467478+morluto@users.noreply.github.com>
This commit is contained in:
@@ -0,0 +1,98 @@
|
||||
import { access, mkdir, readFile, writeFile } from "node:fs/promises";
|
||||
import { join } from "node:path";
|
||||
import { parse } from "yaml";
|
||||
import { expect } from "vitest";
|
||||
|
||||
import { createTestTempDirectory } from "../../fixtures/temporaryDirectory.js";
|
||||
import { cliTest } from "../../support/cli/cliFixture.js";
|
||||
|
||||
cliTest(
|
||||
"Hermes setup, doctor and uninstall use the expanded profile and its personal skill",
|
||||
async ({ cli }) => {
|
||||
const home = await createTestTempDirectory("rea-hermes-cli-");
|
||||
const profile = join(home, "profile");
|
||||
const config = join(profile, "config.yaml");
|
||||
const skill = join(profile, "skills/reverse-engineer-anything/SKILL.md");
|
||||
const original =
|
||||
"# user settings\nmodel: custom\nmcp_servers:\n other:\n command: other-server\n";
|
||||
await mkdir(profile);
|
||||
await writeFile(config, original);
|
||||
const run = (arguments_: readonly string[]) =>
|
||||
cli.run({
|
||||
arguments: arguments_,
|
||||
cwd: home,
|
||||
environment: {
|
||||
HOME: home,
|
||||
USERPROFILE: home,
|
||||
HERMES_HOME: " ${HOME}/profile ",
|
||||
},
|
||||
timeoutMs: 20_000,
|
||||
});
|
||||
const planned = await run([
|
||||
"setup",
|
||||
"--client",
|
||||
"hermes",
|
||||
"--dry-run",
|
||||
"--json",
|
||||
]);
|
||||
expect(planned.exitCode).toBe(0);
|
||||
expect(planned.json).toMatchObject({
|
||||
status: "planned",
|
||||
plannedActions: expect.arrayContaining([
|
||||
expect.objectContaining({ target: config }),
|
||||
expect.objectContaining({
|
||||
target: join(profile, "skills/reverse-engineer-anything"),
|
||||
}),
|
||||
]),
|
||||
});
|
||||
expect(await readFile(config, "utf8")).toBe(original);
|
||||
await expect(access(skill)).rejects.toMatchObject({ code: "ENOENT" });
|
||||
const applied = await run([
|
||||
"setup",
|
||||
"--client",
|
||||
"hermes",
|
||||
"--yes",
|
||||
"--json",
|
||||
]);
|
||||
expect(applied.exitCode).toBe(0);
|
||||
expect(applied.json).toMatchObject({ status: "ready" });
|
||||
expect(parse(await readFile(config, "utf8"))).toMatchObject({
|
||||
model: "custom",
|
||||
mcp_servers: {
|
||||
other: { command: "other-server" },
|
||||
rea: { enabled: true },
|
||||
},
|
||||
});
|
||||
expect(await readFile(config + ".rea.backup", "utf8")).toBe(original);
|
||||
expect(await readFile(skill, "utf8")).toContain(
|
||||
"reverse-engineer-anything",
|
||||
);
|
||||
await expect(
|
||||
access(join(home, ".agents/skills/reverse-engineer-anything/SKILL.md")),
|
||||
).rejects.toMatchObject({ code: "ENOENT" });
|
||||
const doctor = await run([
|
||||
"doctor",
|
||||
"--client",
|
||||
"hermes",
|
||||
"--skill",
|
||||
"--json",
|
||||
]);
|
||||
expect(doctor.exitCode).toBe(0);
|
||||
expect(doctor.json).toMatchObject({
|
||||
healthy: true,
|
||||
identity: { skill: { state: "aligned" } },
|
||||
});
|
||||
const repeat = await run([
|
||||
"setup",
|
||||
"--client",
|
||||
"hermes",
|
||||
"--yes",
|
||||
"--json",
|
||||
]);
|
||||
expect(repeat.json).toMatchObject({ status: "ready", appliedActions: [] });
|
||||
const uninstall = await run(["uninstall", "--json"]);
|
||||
expect(uninstall.exitCode).toBe(0);
|
||||
expect(parse(await readFile(config, "utf8"))).toEqual(parse(original));
|
||||
await expect(access(skill)).rejects.toMatchObject({ code: "ENOENT" });
|
||||
},
|
||||
);
|
||||
@@ -63,6 +63,7 @@ describe("client configuration filesystem lifecycle", () => {
|
||||
"vscode",
|
||||
"grok_build",
|
||||
"omp",
|
||||
"hermes",
|
||||
"grok_bot",
|
||||
]);
|
||||
expect(
|
||||
|
||||
@@ -0,0 +1,165 @@
|
||||
import { mkdir, readFile, writeFile } from "node:fs/promises";
|
||||
import { join } from "node:path";
|
||||
|
||||
import { afterEach, beforeEach, describe, expect, it, vi } from "vitest";
|
||||
import { parse as parseYaml } from "yaml";
|
||||
|
||||
import { readClientRegistrationStatuses } from "../../../src/application/ClientRegistrationStatus.js";
|
||||
import { npxRegistrationCommand } from "../../../src/application/ClientRegistrationIdentity.js";
|
||||
import { configureClientConfiguration } from "../../../src/application/SetupClientConfiguration.js";
|
||||
import { supportedClients } from "../../../src/application/SupportedClients.js";
|
||||
import { systemUninstallHost } from "../../../src/application/Uninstall.js";
|
||||
import { createTestTempDirectory } from "../../fixtures/temporaryDirectory.js";
|
||||
import { clearClientLocationEnvironment } from "../../fixtures/clientEnvironment.js";
|
||||
|
||||
/**
|
||||
* The registration command setup writes on the host running the tests. Windows
|
||||
* wraps it in `cmd.exe /d /c`, so the expected entry follows the host too.
|
||||
*/
|
||||
const command = npxRegistrationCommand(process.platform);
|
||||
|
||||
beforeEach(clearClientLocationEnvironment);
|
||||
afterEach(() => vi.unstubAllEnvs());
|
||||
|
||||
const hermesPath = (
|
||||
env: Parameters<typeof supportedClients>[2],
|
||||
platform: NodeJS.Platform = "linux",
|
||||
) =>
|
||||
supportedClients(join("/home/a"), platform, env).find(
|
||||
({ name }) => name === "hermes",
|
||||
);
|
||||
|
||||
describe("Hermes configuration paths", () => {
|
||||
it("resolves config.yaml under the platform Hermes home", () => {
|
||||
expect(hermesPath({})).toEqual({
|
||||
name: "hermes",
|
||||
displayName: "Hermes",
|
||||
configPath: join("/home/a", ".hermes", "config.yaml"),
|
||||
markerPath: join("/home/a", ".hermes"),
|
||||
format: "hermes",
|
||||
});
|
||||
// Windows uses the native data directory, matching Hermes's own resolver.
|
||||
expect(
|
||||
hermesPath({ LOCALAPPDATA: "C:\\Users\\a\\AppData\\Local" }, "win32")
|
||||
?.configPath,
|
||||
).toBe(join("C:\\Users\\a\\AppData\\Local", "hermes", "config.yaml"));
|
||||
});
|
||||
|
||||
it("expands and trims Hermes overrides without changing the suffix", () => {
|
||||
expect(hermesPath({ HERMES_HOME: " ~/profile " })?.markerPath).toBe(
|
||||
join("/home/a", "profile"),
|
||||
);
|
||||
expect(
|
||||
hermesPath({
|
||||
HERMES_HOME: "${PROFILE_ROOT}/agent",
|
||||
PROFILE_ROOT: "/custom",
|
||||
})?.markerPath,
|
||||
).toBe(join("/custom", "agent"));
|
||||
expect(
|
||||
hermesPath({
|
||||
HERMES_HOME: "$PROFILE_ROOT/agent",
|
||||
PROFILE_ROOT: "/custom",
|
||||
})?.markerPath,
|
||||
).toBe(join("/custom", "agent"));
|
||||
expect(hermesPath({ LOCALAPPDATA: " " }, "win32")?.markerPath).toBe(
|
||||
join("/home/a", "AppData", "Local", "hermes"),
|
||||
);
|
||||
});
|
||||
|
||||
it("honours HERMES_HOME and Hermes's data-directory suffix", () => {
|
||||
expect(
|
||||
hermesPath({ HERMES_HOME: join("/srv", "hermes") })?.configPath,
|
||||
).toBe(join("/srv", "hermes", "config.yaml"));
|
||||
// A blank override falls through to the platform default.
|
||||
expect(hermesPath({ HERMES_HOME: " " })?.configPath).toBe(
|
||||
join("/home/a", ".hermes", "config.yaml"),
|
||||
);
|
||||
// Hermes appends the suffix to the literal directory name.
|
||||
expect(hermesPath({ HERMES_DATA_DIR_SUFFIX: "-dev" })?.configPath).toBe(
|
||||
join("/home/a", ".hermes-dev", "config.yaml"),
|
||||
);
|
||||
expect(
|
||||
hermesPath(
|
||||
{
|
||||
HERMES_DATA_DIR_SUFFIX: "-dev",
|
||||
LOCALAPPDATA: "C:\\Users\\a\\AppData\\Local",
|
||||
},
|
||||
"win32",
|
||||
)?.configPath,
|
||||
).toBe(join("C:\\Users\\a\\AppData\\Local", "hermes-dev", "config.yaml"));
|
||||
});
|
||||
});
|
||||
|
||||
describe("Hermes YAML registration", () => {
|
||||
const hermesClient = async () => {
|
||||
const home = await createTestTempDirectory("rea-hermes-");
|
||||
const client = supportedClients(home, process.platform, {}).find(
|
||||
({ name }) => name === "hermes",
|
||||
);
|
||||
if (client?.markerPath === undefined)
|
||||
throw new Error("missing Hermes client");
|
||||
await mkdir(client.markerPath, { recursive: true });
|
||||
return { home, client };
|
||||
};
|
||||
|
||||
it("writes mcp_servers, preserves comments, reads back, and uninstalls", async () => {
|
||||
const { home, client } = await hermesClient();
|
||||
await writeFile(
|
||||
client.configPath,
|
||||
`# Hermes configuration
|
||||
display:
|
||||
language: en
|
||||
mcp_servers:
|
||||
# An independently managed server.
|
||||
other:
|
||||
command: other-server
|
||||
`,
|
||||
);
|
||||
|
||||
expect(
|
||||
(await configureClientConfiguration(client, {}, command)).status,
|
||||
).toBe("configured");
|
||||
const text = await readFile(client.configPath, "utf8");
|
||||
expect(text).toContain("# Hermes configuration");
|
||||
expect(text).toContain("# An independently managed server.");
|
||||
expect(parseYaml(text)).toEqual({
|
||||
display: { language: "en" },
|
||||
mcp_servers: {
|
||||
other: { command: "other-server" },
|
||||
rea: { command: command[0], args: command.slice(1), enabled: true },
|
||||
},
|
||||
});
|
||||
|
||||
expect(await configureClientConfiguration(client, {}, command)).toEqual({
|
||||
status: "unchanged",
|
||||
});
|
||||
expect(
|
||||
(
|
||||
await readClientRegistrationStatuses(home, undefined, {
|
||||
platform: process.platform,
|
||||
environment: {},
|
||||
})
|
||||
).find(({ client: name }) => name === "hermes"),
|
||||
).toMatchObject({ state: "aligned", command });
|
||||
|
||||
expect((await systemUninstallHost(home).removeClient(client)).status).toBe(
|
||||
"removed",
|
||||
);
|
||||
expect(parseYaml(await readFile(client.configPath, "utf8"))).toEqual({
|
||||
display: { language: "en" },
|
||||
mcp_servers: { other: { command: "other-server" } },
|
||||
});
|
||||
});
|
||||
|
||||
it("creates config.yaml when Hermes has no configuration yet", async () => {
|
||||
const { client } = await hermesClient();
|
||||
expect(
|
||||
(await configureClientConfiguration(client, {}, command)).status,
|
||||
).toBe("configured");
|
||||
expect(parseYaml(await readFile(client.configPath, "utf8"))).toEqual({
|
||||
mcp_servers: {
|
||||
rea: { command: command[0], args: command.slice(1), enabled: true },
|
||||
},
|
||||
});
|
||||
});
|
||||
});
|
||||
@@ -13,7 +13,6 @@ import { createTestTempDirectory } from "../../fixtures/temporaryDirectory.js";
|
||||
|
||||
import {
|
||||
canonicalSkillNeedsInstall,
|
||||
claudeCodeSkillsDirectory,
|
||||
installCanonicalSkill,
|
||||
} from "../../../src/application/SetupSkill.js";
|
||||
import {
|
||||
@@ -56,9 +55,7 @@ describe("canonical skill transaction", () => {
|
||||
it("installs only the selected Claude Code personal skill", async () => {
|
||||
const home = await createTestTempDirectory("rea-claude-skill-");
|
||||
const configDirectory = join(home, "claude-config");
|
||||
const skillsDirectory = claudeCodeSkillsDirectory(home, {
|
||||
CLAUDE_CONFIG_DIR: configDirectory,
|
||||
});
|
||||
const skillsDirectory = join(configDirectory, "skills");
|
||||
const claudeSkill = join(
|
||||
skillsDirectory,
|
||||
"reverse-engineer-anything/SKILL.md",
|
||||
@@ -84,13 +81,19 @@ describe("canonical skill transaction", () => {
|
||||
});
|
||||
|
||||
expect(
|
||||
await canonicalSkillNeedsInstall(home, ["claude_code"], skillsDirectory),
|
||||
await canonicalSkillNeedsInstall(home, ["claude_code"], {
|
||||
CLAUDE_CONFIG_DIR: dirname(skillsDirectory),
|
||||
}),
|
||||
).toBe(true);
|
||||
expect(
|
||||
await installCanonicalSkill(home, ["claude_code"], skillsDirectory),
|
||||
await installCanonicalSkill(home, ["claude_code"], {
|
||||
CLAUDE_CONFIG_DIR: dirname(skillsDirectory),
|
||||
}),
|
||||
).toBe("installed");
|
||||
expect(
|
||||
await canonicalSkillNeedsInstall(home, ["claude_code"], skillsDirectory),
|
||||
await canonicalSkillNeedsInstall(home, ["claude_code"], {
|
||||
CLAUDE_CONFIG_DIR: dirname(skillsDirectory),
|
||||
}),
|
||||
).toBe(false);
|
||||
await expect(access(claudeSkill)).resolves.toBeUndefined();
|
||||
await expect(
|
||||
@@ -112,7 +115,7 @@ describe("canonical skill transaction", () => {
|
||||
home,
|
||||
".agents/skills/reverse-engineer-anything/SKILL.md",
|
||||
);
|
||||
const claudeSkills = claudeCodeSkillsDirectory(home);
|
||||
const claudeSkills = join(home, ".claude", "skills");
|
||||
const claudeSkill = join(
|
||||
claudeSkills,
|
||||
"reverse-engineer-anything/SKILL.md",
|
||||
|
||||
Vendored
+3
@@ -17,6 +17,9 @@ export const CLIENT_LOCATION_ENVIRONMENT = [
|
||||
"CODEX_HOME",
|
||||
"COPILOT_HOME",
|
||||
"GROK_HOME",
|
||||
"HERMES_DATA_DIR_SUFFIX",
|
||||
"HERMES_HOME",
|
||||
"LOCALAPPDATA",
|
||||
"OMP_PROFILE",
|
||||
"OPENCODE_CONFIG",
|
||||
"PI_CODING_AGENT_DIR",
|
||||
|
||||
Reference in New Issue
Block a user