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
@@ -1037,6 +1037,47 @@ export const grokServerListedDisabled = (
Array.isArray(document.disabled_mcp_servers) &&
document.disabled_mcp_servers.includes(serverKey);
/**
* OMP's user `disabledServers` denylist hides a server by name regardless of
* its entry, so a listed REA registration is not loaded.
*/
export const OMP_DISABLED_SERVERS_KEY = "disabledServers";
/** Whether OMP's root `disabledServers` denylist names `serverKey`. */
export const ompServerListedDisabled = (
document: Record<string, unknown>,
serverKey: string,
): boolean => {
const listed = document[OMP_DISABLED_SERVERS_KEY];
return Array.isArray(listed) && listed.includes(serverKey);
};
/** OMP's user `enabledServers` allowlist overrides an entry's `enabled: false`. */
const OMP_ENABLED_SERVERS_KEY = "enabledServers";
/**
* Whether OMP's allowlist forces `serverKey` on despite its entry's
* `enabled: false`. The `disabledServers` denylist still wins over it.
*/
export const clientServerForcedEnabled = (
parsed: ClientConfigurationDocument,
serverKey: string,
): boolean => {
if (parsed.dialect !== "omp") return false;
const listed = parsed.document[OMP_ENABLED_SERVERS_KEY];
return Array.isArray(listed) && listed.includes(serverKey);
};
/** Whether a client's own disable list suppresses `serverKey`. */
export const clientServerListedDisabled = (
parsed: ClientConfigurationDocument,
serverKey: string,
): boolean =>
(parsed.dialect === "grok" &&
grokServerListedDisabled(parsed.document, serverKey)) ||
(parsed.dialect === "omp" &&
ompServerListedDisabled(parsed.document, serverKey));
/** Keep an existing Grok document intact aside from the REA server tables. */
const serializeGrokConfiguration = (
document: Record<string, unknown>,
@@ -1289,6 +1330,7 @@ export const clientRegistrationEntry = (
: { environment: { ...environment } }),
};
case "vscode":
case "omp":
return {
type: "stdio",
command: executable,
+26 -9
View File
@@ -1,6 +1,7 @@
import {
clientServerForcedEnabled,
clientServerListedDisabled,
effectiveClientServer,
grokServerListedDisabled,
parseClientConfiguration,
} from "./ClientConfigurationDocument.js";
import { access, readFile } from "node:fs/promises";
@@ -85,7 +86,11 @@ export const readClientRegistrationStatuses = async (
CODEX_HOME: options.environment.CODEX_HOME,
COPILOT_HOME: options.environment.COPILOT_HOME,
GROK_HOME: options.environment.GROK_HOME,
OMP_PROFILE: options.environment.OMP_PROFILE,
OPENCODE_CONFIG: options.environment.OPENCODE_CONFIG,
PI_CODING_AGENT_DIR: options.environment.PI_CODING_AGENT_DIR,
PI_CONFIG_DIR: options.environment.PI_CONFIG_DIR,
PI_PROFILE: options.environment.PI_PROFILE,
SAND_DATA_ROOT: options.environment.SAND_DATA_ROOT,
XDG_CONFIG_HOME: options.environment.XDG_CONFIG_HOME,
},
@@ -132,14 +137,9 @@ export const readClientRegistrationStatuses = async (
client,
currentCommandPath,
options.platform ?? process.platform,
clientServerForcedEnabled(parsed, PRODUCT_IDENTITY.mcpServerKey),
) &&
!(
client.format === "grok" &&
grokServerListedDisabled(
parsed.document,
PRODUCT_IDENTITY.mcpServerKey,
)
)
!clientServerListedDisabled(parsed, PRODUCT_IDENTITY.mcpServerKey)
? "aligned"
: "stale",
),
@@ -164,9 +164,13 @@ const registrationAligned = (
client: SetupClient,
currentCommandPath: string,
platform: NodeJS.Platform,
forcedEnabled = false,
): boolean => {
const command = [registration.command, ...registration.args];
if (registration.disabled === true || registration.enabled === false)
if (
registration.disabled === true ||
(registration.enabled === false && !forcedEnabled)
)
return false;
if (!isOwnedClientRegistrationCommand(command, currentCommandPath))
return false;
@@ -177,6 +181,13 @@ const registrationAligned = (
)
return false;
if (client.format === "vscode" && registration.type !== "stdio") return false;
// OMP infers stdio for a command entry without an explicit type.
if (
client.format === "omp" &&
registration.type !== undefined &&
registration.type !== "stdio"
)
return false;
if (
client.format === "copilot_cli" &&
(registration.type !== "stdio" ||
@@ -233,6 +244,12 @@ const parseRegistration = (
throw new TypeError("Expected an stdio registration");
if (client.format === "commandcode" && registration.transport !== "stdio")
throw new TypeError("Expected an stdio registration");
if (
client.format === "omp" &&
registration.type !== undefined &&
registration.type !== "stdio"
)
throw new TypeError("Expected an stdio registration");
return registration;
};
+23 -7
View File
@@ -1,9 +1,10 @@
import {
clientRegistrationEntry,
clientConfigurationValuesEqual,
clientServerListedDisabled,
clientServerPath,
grokServerListedDisabled,
legacyClientServerPath,
OMP_DISABLED_SERVERS_KEY,
parseClientConfiguration,
serializeClientConfiguration,
withClientServers,
@@ -85,11 +86,28 @@ const configureClientDocument = async (
parsed,
PRODUCT_IDENTITY.mcpServerKey,
);
const document = withClientServers(
const registered = withClientServers(
parsed,
{ ...parsed.servers, [PRODUCT_IDENTITY.mcpServerKey]: desired },
PRODUCT_IDENTITY.mcpServerKey,
);
// OMP's denylist would hide the registration; keep every other listed name.
const ompDisabled =
parsed.dialect === "omp"
? parsed.document[OMP_DISABLED_SERVERS_KEY]
: undefined;
const enableOmp =
Array.isArray(ompDisabled) &&
ompDisabled.includes(PRODUCT_IDENTITY.mcpServerKey);
const document =
enableOmp && Array.isArray(ompDisabled)
? {
...registered,
[OMP_DISABLED_SERVERS_KEY]: ompDisabled.filter(
(name: unknown) => name !== PRODUCT_IDENTITY.mcpServerKey,
),
}
: registered;
try {
await mkdir(dirname(client.configPath), { recursive: true });
await writeFileAtomic(
@@ -97,6 +115,7 @@ const configureClientDocument = async (
serializeClientConfiguration(document, format, original, [
clientServerPath(parsed, PRODUCT_IDENTITY.mcpServerKey),
...(legacyPath === undefined ? [] : [legacyPath]),
...(enableOmp ? [[OMP_DISABLED_SERVERS_KEY]] : []),
]),
{
encoding: "utf8",
@@ -233,7 +252,7 @@ const restoreConfig = async (
}
};
/** Whether REA's entry matches, no legacy entry remains, and Grok is not suppressing it. */
/** Whether REA's entry matches, no legacy entry remains, and no client disable list suppresses it. */
const registrationCurrent = (
parsed: ClientConfigurationDocument,
desired: unknown,
@@ -243,10 +262,7 @@ const registrationCurrent = (
desired,
) &&
!Object.hasOwn(parsed.legacyServers, PRODUCT_IDENTITY.mcpServerKey) &&
!(
parsed.dialect === "grok" &&
grokServerListedDisabled(parsed.document, PRODUCT_IDENTITY.mcpServerKey)
);
!clientServerListedDisabled(parsed, PRODUCT_IDENTITY.mcpServerKey);
const clientConfigurationDesired = (
client: SetupClient,
+51
View File
@@ -15,6 +15,7 @@ export interface SetupClient {
| "opencode"
| "commandcode"
| "grok"
| "omp"
| "unsupported";
}
@@ -29,7 +30,11 @@ interface ClientPathContext {
readonly CODEX_HOME?: string | undefined;
readonly COPILOT_HOME?: string | undefined;
readonly GROK_HOME?: string | undefined;
readonly OMP_PROFILE?: string | undefined;
readonly OPENCODE_CONFIG?: string | undefined;
readonly PI_CODING_AGENT_DIR?: string | undefined;
readonly PI_CONFIG_DIR?: string | undefined;
readonly PI_PROFILE?: string | undefined;
readonly SAND_DATA_ROOT?: string | undefined;
readonly XDG_CONFIG_HOME?: string | undefined;
};
@@ -106,6 +111,40 @@ export const manualRegistrationRemediation = (
? GROK_BOT_MANUAL_REGISTRATION_REMEDIATION
: undefined;
const OMP_PROFILE_NAME = /^[a-z0-9][a-z0-9._-]{0,63}$/u;
/**
* OMP's active named profile. OMP_PROFILE wins over the legacy PI_PROFILE even
* when empty; empty and "default" select the default profile. OMP refuses to
* start with an invalid name, so one leaves the default location in place.
*/
const ompProfile = ({ env }: ClientPathContext): string | undefined => {
const name = (env.OMP_PROFILE ?? env.PI_PROFILE)?.trim();
return name === undefined ||
name === "" ||
name === "default" ||
name.endsWith(".") ||
!OMP_PROFILE_NAME.test(name)
? undefined
: name;
};
/**
* The OMP agent directory whose `mcp.json` holds user-scope MCP servers. OMP
* joins PI_CONFIG_DIR to the home directory, and a named profile ignores
* PI_CODING_AGENT_DIR. OMP resolves a relative agent directory against each
* process's working directory, so only an absolute override names one file.
*/
const ompAgentDirectory = (context: ClientPathContext): string => {
const root = join(context.home, context.env.PI_CONFIG_DIR || ".omp");
const profile = ompProfile(context);
if (profile !== undefined) return join(root, "profiles", profile, "agent");
const override = context.env.PI_CODING_AGENT_DIR;
return override !== undefined && override !== "" && isAbsolute(override)
? override
: join(root, "agent");
};
const copilotDirectory = ({ home, env }: ClientPathContext): string =>
env.COPILOT_HOME ?? join(home, ".copilot");
@@ -249,6 +288,14 @@ export const SUPPORTED_CLIENT_DEFINITIONS = [
markerPath: grokDirectory,
format: "grok",
},
{
name: "omp",
displayName: "OMP",
configPath: (context: ClientPathContext) =>
join(ompAgentDirectory(context), "mcp.json"),
markerPath: ompAgentDirectory,
format: "omp",
},
{
name: "grok_bot",
displayName: "Grok Bot",
@@ -271,7 +318,11 @@ export const supportedClients = (
CODEX_HOME: process.env.CODEX_HOME,
COPILOT_HOME: process.env.COPILOT_HOME,
GROK_HOME: process.env.GROK_HOME,
OMP_PROFILE: process.env.OMP_PROFILE,
OPENCODE_CONFIG: process.env.OPENCODE_CONFIG,
PI_CODING_AGENT_DIR: process.env.PI_CODING_AGENT_DIR,
PI_CONFIG_DIR: process.env.PI_CONFIG_DIR,
PI_PROFILE: process.env.PI_PROFILE,
SAND_DATA_ROOT: process.env.SAND_DATA_ROOT,
XDG_CONFIG_HOME: process.env.XDG_CONFIG_HOME,
},
+7 -1
View File
@@ -6,6 +6,7 @@ import { PRODUCT_IDENTITY } from "../identity.js";
import { isOwnedClientRegistrationCommand } from "./ClientRegistrationIdentity.js";
import { readClientRegistrationStatuses } from "./ClientRegistrationStatus.js";
import {
clientServerForcedEnabled,
effectiveClientServer,
parseClientConfiguration,
} from "./ClientConfigurationDocument.js";
@@ -76,7 +77,12 @@ export const existingMaintenanceScope = async (
disabled: z.boolean().optional(),
})
.parse(effectiveClientServer(parsed, PRODUCT_IDENTITY.mcpServerKey));
if (enabled.enabled !== false && enabled.disabled !== true)
// OMP's enabledServers allowlist runs an entry marked `enabled: false`.
if (
(enabled.enabled !== false ||
clientServerForcedEnabled(parsed, PRODUCT_IDENTITY.mcpServerKey)) &&
enabled.disabled !== true
)
clients.push(client.name);
}
let skill = false;