feat(setup): register OMP during setup (#1301)

* feat(setup): register OMP during setup

Add OMP (oh-my-pi) as a setup, doctor and uninstall client. Setup writes
a type: stdio entry to the user-level agent mcp.json that OMP reads,
following PI_CONFIG_DIR, an absolute PI_CODING_AGENT_DIR and the
OMP_PROFILE/PI_PROFILE named profile. It removes rea from OMP's
disabledServers denylist, which would otherwise hide the registration,
and doctor reports a listed registration as stale.

Closes #1257

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>

* fix(setup): honor OMP's enabledServers allowlist in doctor

OMP's user enabledServers allowlist forces an entry with enabled: false
on, unless disabledServers also lists it. Doctor reported such a working
registration as stale. Also format the FAQ client list.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>

* fix(setup): keep OMP's allowlisted entry in update maintenance

rea update skipped an owned OMP entry with enabled: false even when
OMP's enabledServers allowlist runs it. Apply the same forced-enable rule
as doctor. Share the client-location environment reset across the client
tests instead of repeating it in each file.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>

---------

Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
Kaoru0822
2026-10-09 08:51:12 -07:00
committed by GitHub
co-authored by Claude Opus 5.5
parent 24673aaae4
commit 8b4c359135
19 changed files with 412 additions and 61 deletions
@@ -11,6 +11,7 @@ import { supportedClients } from "../../../src/application/SupportedClients.js";
import { PRODUCT_IDENTITY } from "../../../src/identity.js";
import { isOwnedClientRegistrationCommand } from "../../../src/application/ClientRegistrationIdentity.js";
import { createTestTempDirectory } from "../../fixtures/temporaryDirectory.js";
import { clearClientLocationEnvironment } from "../../fixtures/clientEnvironment.js";
const command = [
"npx",
@@ -19,19 +20,7 @@ const command = [
"mcp",
] as const;
beforeEach(() => {
for (const name of [
"APPDATA",
"CLAUDE_CONFIG_DIR",
"CODEX_HOME",
"COPILOT_HOME",
"GROK_HOME",
"OPENCODE_CONFIG",
"SAND_DATA_ROOT",
"XDG_CONFIG_HOME",
])
vi.stubEnv(name, undefined);
});
beforeEach(clearClientLocationEnvironment);
afterEach(() => vi.unstubAllEnvs());
@@ -44,6 +33,7 @@ const getClients = (home: string) =>
"commandcode",
"vscode",
"devin",
"omp",
].includes(name),
);
@@ -55,6 +45,7 @@ describe("additional client configuration dialects", () => {
"commandcode",
"vscode",
"devin",
"omp",
] as const)("registers, reads back, and uninstalls %s", async (name) => {
const home = await createTestTempDirectory("rea-client-dialect-");
const client = getClients(home).find(
@@ -89,7 +80,7 @@ describe("additional client configuration dialects", () => {
command,
enabled: true,
});
if (name === "vscode")
if (name === "vscode" || name === "omp")
expect(registration).toMatchObject({
type: "stdio",
command: "npx",
@@ -15,6 +15,7 @@ import { afterEach, beforeEach, describe, expect, it, vi } from "vitest";
import { parse as parseJsonc, type ParseError } from "jsonc-parser";
import { createTestTempDirectory } from "../../fixtures/temporaryDirectory.js";
import { clearClientLocationEnvironment } from "../../fixtures/clientEnvironment.js";
import { supportedClients } from "../../../src/application/SupportedClients.js";
import { readClientRegistrationStatuses } from "../../../src/application/ClientRegistrationStatus.js";
@@ -30,19 +31,7 @@ import {
} from "../../../src/application/Uninstall.js";
const roots: string[] = [];
beforeEach(() => {
for (const name of [
"APPDATA",
"CLAUDE_CONFIG_DIR",
"CODEX_HOME",
"COPILOT_HOME",
"GROK_HOME",
"OPENCODE_CONFIG",
"SAND_DATA_ROOT",
"XDG_CONFIG_HOME",
])
vi.stubEnv(name, undefined);
});
beforeEach(clearClientLocationEnvironment);
afterEach(async () => {
vi.unstubAllEnvs();
await Promise.all(
@@ -72,6 +61,7 @@ describe("client configuration filesystem lifecycle", () => {
"commandcode",
"vscode",
"grok_build",
"omp",
"grok_bot",
]);
expect(
@@ -4,23 +4,12 @@ import { join, resolve } from "node:path";
import { afterEach, beforeEach, describe, expect, it, vi } from "vitest";
import { createTestTempDirectory } from "../../fixtures/temporaryDirectory.js";
import { clearClientLocationEnvironment } from "../../fixtures/clientEnvironment.js";
import { readClientRegistrationStatuses } from "../../../src/application/ClientRegistrationStatus.js";
import { PRODUCT_IDENTITY } from "../../../src/identity.js";
beforeEach(() => {
for (const name of [
"APPDATA",
"CLAUDE_CONFIG_DIR",
"CODEX_HOME",
"COPILOT_HOME",
"GROK_HOME",
"OPENCODE_CONFIG",
"SAND_DATA_ROOT",
"XDG_CONFIG_HOME",
])
vi.stubEnv(name, undefined);
});
beforeEach(clearClientLocationEnvironment);
afterEach(() => {
vi.unstubAllEnvs();
});
@@ -0,0 +1,174 @@
import { mkdir, readFile, writeFile } from "node:fs/promises";
import { join, resolve } from "node:path";
import { afterEach, beforeEach, describe, expect, it, vi } from "vitest";
import { parse as parseJsonc } from "jsonc-parser";
import { readClientRegistrationStatuses } from "../../../src/application/ClientRegistrationStatus.js";
import { configureClientConfiguration } from "../../../src/application/SetupClientConfiguration.js";
import { supportedClients } from "../../../src/application/SupportedClients.js";
import { systemUninstallHost } from "../../../src/application/Uninstall.js";
import { PRODUCT_IDENTITY } from "../../../src/identity.js";
import { createTestTempDirectory } from "../../fixtures/temporaryDirectory.js";
import { clearClientLocationEnvironment } from "../../fixtures/clientEnvironment.js";
const command = [
"npx",
"-y",
PRODUCT_IDENTITY.registrationPackageSpecifier,
"mcp",
] as const;
beforeEach(clearClientLocationEnvironment);
afterEach(() => vi.unstubAllEnvs());
const ompPath = (env: Parameters<typeof supportedClients>[2]) =>
supportedClients("/home/a", "linux", env).find(({ name }) => name === "omp");
describe("OMP configuration paths", () => {
it("uses the default agent directory and OMP's environment overrides", () => {
expect(ompPath({})).toEqual({
name: "omp",
displayName: "OMP",
configPath: "/home/a/.omp/agent/mcp.json",
markerPath: "/home/a/.omp/agent",
format: "omp",
});
// OMP joins PI_CONFIG_DIR to the home directory.
expect(ompPath({ PI_CONFIG_DIR: ".pi" })?.configPath).toBe(
"/home/a/.pi/agent/mcp.json",
);
expect(ompPath({ PI_CODING_AGENT_DIR: "/custom/agent" })?.configPath).toBe(
"/custom/agent/mcp.json",
);
// A relative override names a different file in every working directory.
expect(ompPath({ PI_CODING_AGENT_DIR: "agent" })?.configPath).toBe(
"/home/a/.omp/agent/mcp.json",
);
});
it("follows the active named profile like OMP", () => {
expect(
ompPath({ OMP_PROFILE: "work", PI_CODING_AGENT_DIR: "/custom/agent" })
?.configPath,
).toBe("/home/a/.omp/profiles/work/agent/mcp.json");
expect(ompPath({ PI_PROFILE: "legacy" })?.configPath).toBe(
"/home/a/.omp/profiles/legacy/agent/mcp.json",
);
// An explicitly empty OMP_PROFILE selects the default over PI_PROFILE.
expect(ompPath({ OMP_PROFILE: "", PI_PROFILE: "legacy" })?.configPath).toBe(
"/home/a/.omp/agent/mcp.json",
);
for (const profile of ["default", " ", "Bad Name", "trailing."])
expect(ompPath({ OMP_PROFILE: profile })?.configPath).toBe(
"/home/a/.omp/agent/mcp.json",
);
});
});
describe("OMP disabledServers denylist", () => {
const ompClient = async () => {
const home = await createTestTempDirectory("rea-omp-");
const client = supportedClients(home, process.platform, {}).find(
({ name }) => name === "omp",
);
if (client?.markerPath === undefined) throw new Error("missing OMP client");
await mkdir(client.markerPath, { recursive: true });
return { home, client };
};
it("removes rea from disabledServers while keeping other names and comments", async () => {
const { home, client } = await ompClient();
await writeFile(
client.configPath,
`{
// Keep this note.
"mcpServers": { "other": { "command": "other-server" } },
"disabledServers": ["other", "rea"]
}
`,
);
expect(
(await configureClientConfiguration(client, {}, command)).status,
).toBe("configured");
const text = await readFile(client.configPath, "utf8");
expect(text).toContain("// Keep this note.");
expect(parseJsonc(text)).toEqual({
mcpServers: {
other: { command: "other-server" },
rea: { type: "stdio", command: "npx", args: command.slice(1) },
},
disabledServers: ["other"],
});
expect(await configureClientConfiguration(client, {}, command)).toEqual({
status: "unchanged",
});
expect((await systemUninstallHost(home).removeClient(client)).status).toBe(
"removed",
);
expect(parseJsonc(await readFile(client.configPath, "utf8"))).toEqual({
mcpServers: { other: { command: "other-server" } },
disabledServers: ["other"],
});
});
it("reports a registration hidden by disabledServers as stale", async () => {
const { home, client } = await ompClient();
const entry = resolve("scripts/rea.mjs");
const registration = {
command: process.execPath,
args: [entry, "mcp"],
};
await writeFile(
client.configPath,
JSON.stringify({
mcpServers: { rea: registration },
disabledServers: ["rea"],
}),
);
const status = async () =>
(
await readClientRegistrationStatuses(home, entry, { environment: {} })
).find(({ client: name }) => name === "omp");
expect(await status()).toMatchObject({ state: "stale" });
// The enabledServers allowlist forces an `enabled: false` entry on, but
// the disabledServers denylist still wins over it.
const disabledEntry = { ...registration, enabled: false };
await writeFile(
client.configPath,
JSON.stringify({ mcpServers: { rea: disabledEntry } }),
);
expect(await status()).toMatchObject({ state: "stale" });
await writeFile(
client.configPath,
JSON.stringify({
mcpServers: { rea: disabledEntry },
enabledServers: ["rea"],
}),
);
expect(await status()).toMatchObject({ state: "aligned" });
await writeFile(
client.configPath,
JSON.stringify({
mcpServers: { rea: disabledEntry },
enabledServers: ["rea"],
disabledServers: ["rea"],
}),
);
expect(await status()).toMatchObject({ state: "stale" });
// OMP infers stdio for a command entry without an explicit type.
await writeFile(
client.configPath,
JSON.stringify({ mcpServers: { rea: registration } }),
);
expect(await status()).toMatchObject({ state: "aligned" });
await writeFile(
client.configPath,
JSON.stringify({
mcpServers: { rea: { ...registration, type: "http" } },
}),
);
expect(await status()).toMatchObject({ state: "invalid" });
expect(join(home, ".omp", "agent", "mcp.json")).toBe(client.configPath);
});
});
+22
View File
@@ -0,0 +1,22 @@
import { vi } from "vitest";
/** Environment variables that redirect where supported clients keep config. */
export const CLIENT_LOCATION_ENVIRONMENT = [
"APPDATA",
"CLAUDE_CONFIG_DIR",
"CODEX_HOME",
"COPILOT_HOME",
"GROK_HOME",
"OMP_PROFILE",
"OPENCODE_CONFIG",
"PI_CODING_AGENT_DIR",
"PI_CONFIG_DIR",
"PI_PROFILE",
"SAND_DATA_ROOT",
"XDG_CONFIG_HOME",
] as const;
/** Clear the developer's client locations so tests resolve only their temporary homes. */
export const clearClientLocationEnvironment = (): void => {
for (const name of CLIENT_LOCATION_ENVIRONMENT) vi.stubEnv(name, undefined);
};
@@ -31,6 +31,10 @@ beforeEach(async () => {
SAND_DATA_ROOT: join(home, ".grokbot"),
XDG_CONFIG_HOME: join(home, ".config"),
OPENCODE_CONFIG: join(home, ".config", "opencode", "opencode.jsonc"),
OMP_PROFILE: undefined,
PI_CODING_AGENT_DIR: undefined,
PI_CONFIG_DIR: undefined,
PI_PROFILE: undefined,
}))
vi.stubEnv(name, value);
});
@@ -75,6 +79,29 @@ const action = {
commands: ["rea mcp"],
};
describe("OMP integration maintenance", () => {
it("refreshes an OMP entry that enabledServers forces on", async () => {
const entry = { type: "stdio", command: entryPoint, args: ["mcp"] };
await writeClient(
"omp",
JSON.stringify({ mcpServers: { rea: { ...entry, enabled: false } } }),
);
await expect(
existingMaintenanceScope(home, entryPoint, process.env),
).resolves.toMatchObject({ clients: [] });
await writeClient(
"omp",
JSON.stringify({
mcpServers: { rea: { ...entry, enabled: false } },
enabledServers: ["rea"],
}),
);
await expect(
existingMaintenanceScope(home, entryPoint, process.env),
).resolves.toMatchObject({ clients: ["omp"] });
});
});
describe("existing REA integration maintenance", () => {
it("selects owned registrations while preserving unconfigured, foreign, and disabled choices", async () => {
await writeClient("codex", staleCodex);