* feat(clients): register Grok Build and Grok Bot during setup Detect both clients and install the local REA MCP registration the same way setup already handles the other agents. Grok Build edits only the REA tables in its TOML config and sets startup_timeout_sec to 30. Grok Bot writes the mcpServers.rea entry into mcp.json. That file is the registration to add to the signed-in account; setup does not call the account API. Filed by Grok. * fix(clients): clear a disabled Grok Build registration during setup Grok Build keeps a server suppressed when its name stays in disabled_mcp_servers, and setup was treating that file as already aligned. Setup now removes only that name, doctor reports the registration stale until it is gone, and uninstall keeps comments in an inline table whose only server was REA. Split the lifecycle suite and reflow the get-started page so static checks pass. * fix(verify): check packed Hopper search as literal-only The package verifier still called a regex probe that main deleted. The native bridge refuses regex and joins string hits with typed records, so the restored probe stubs that inventory and the check asserts the literal matches and the regex refusal. The new README translations also name Grok Build and Grok Bot. * fix(clients): stop treating a Grok Bot data directory as registered Grok Bot stores connectors in the signed-in account and runs them on its hosted computer. Setup no longer writes mcp.json or reports that file as aligned. Doctor and setup tell the caller to add the server from the Grok Bot chat. * fix(clients): drop multiline Grok disable-list entries Decode disabled_mcp_servers strings with the document parser so a multiline basic or literal string that loads as rea is removed. --------- Co-authored-by: Grok <eugene.ray@gmail.com> Co-authored-by: Cursor Agent <cursoragent@cursor.com> Co-authored-by: morluto <morluto@users.noreply.github.com>
288 lines
8.9 KiB
TypeScript
288 lines
8.9 KiB
TypeScript
import { isAbsolute, join } from "node:path";
|
|
import { lstatSync } from "node:fs";
|
|
|
|
/** One supported client configuration location. */
|
|
export interface SetupClient {
|
|
readonly name: string;
|
|
readonly displayName?: string;
|
|
readonly configPath: string;
|
|
readonly markerPath?: string;
|
|
readonly format?:
|
|
| "json"
|
|
| "toml"
|
|
| "vscode"
|
|
| "copilot_cli"
|
|
| "opencode"
|
|
| "commandcode"
|
|
| "grok"
|
|
| "unsupported";
|
|
}
|
|
|
|
type ClientPath = readonly string[] | ((paths: ClientPathContext) => string);
|
|
|
|
interface ClientPathContext {
|
|
readonly home: string;
|
|
readonly platform: NodeJS.Platform;
|
|
readonly env: {
|
|
readonly APPDATA?: string | undefined;
|
|
readonly CLAUDE_CONFIG_DIR?: string | undefined;
|
|
readonly CODEX_HOME?: string | undefined;
|
|
readonly COPILOT_HOME?: string | undefined;
|
|
readonly GROK_HOME?: string | undefined;
|
|
readonly OPENCODE_CONFIG?: string | undefined;
|
|
readonly SAND_DATA_ROOT?: string | undefined;
|
|
readonly XDG_CONFIG_HOME?: string | undefined;
|
|
};
|
|
}
|
|
|
|
interface ClientDefinition {
|
|
readonly name: string;
|
|
readonly displayName: string;
|
|
readonly configPath: ClientPath;
|
|
readonly markerPath: ClientPath;
|
|
readonly format: NonNullable<SetupClient["format"]>;
|
|
}
|
|
|
|
const vscodeUserDirectory = ({
|
|
home,
|
|
platform,
|
|
env,
|
|
}: ClientPathContext): string => {
|
|
if (platform === "win32")
|
|
return join(
|
|
env.APPDATA ?? join(home, "AppData", "Roaming"),
|
|
"Code",
|
|
"User",
|
|
);
|
|
if (platform === "darwin")
|
|
return join(home, "Library", "Application Support", "Code", "User");
|
|
return join(env.XDG_CONFIG_HOME ?? join(home, ".config"), "Code", "User");
|
|
};
|
|
|
|
const claudeDesktopDirectory = ({
|
|
home,
|
|
platform,
|
|
env,
|
|
}: ClientPathContext): string => {
|
|
if (platform === "win32")
|
|
return join(env.APPDATA ?? join(home, "AppData", "Roaming"), "Claude");
|
|
if (platform === "linux")
|
|
return join(env.XDG_CONFIG_HOME ?? join(home, ".config"), "Claude");
|
|
return join(home, "Library", "Application Support", "Claude");
|
|
};
|
|
|
|
const claudeCodeConfigDirectory = ({ home, env }: ClientPathContext): string =>
|
|
env.CLAUDE_CONFIG_DIR ?? home;
|
|
|
|
const claudeCodeMarkerDirectory = ({ home, env }: ClientPathContext): string =>
|
|
env.CLAUDE_CONFIG_DIR ?? join(home, ".claude");
|
|
|
|
const codexDirectory = ({ home, env }: ClientPathContext): string =>
|
|
env.CODEX_HOME ?? join(home, ".codex");
|
|
|
|
const grokDirectory = ({ home, env }: ClientPathContext): string =>
|
|
env.GROK_HOME ?? join(home, ".grok");
|
|
|
|
/** Grok Bot uses an absolute SAND_DATA_ROOT; anything else stays ~/.grokbot. */
|
|
const grokBotDirectory = ({ home, env }: ClientPathContext): string => {
|
|
const root = env.SAND_DATA_ROOT;
|
|
return root !== undefined && root !== "" && isAbsolute(root)
|
|
? root
|
|
: join(home, ".grokbot");
|
|
};
|
|
|
|
/**
|
|
* Grok Bot stores connectors in the signed-in account and runs them on its
|
|
* hosted computer. The data directory is only a detection marker.
|
|
*/
|
|
export const GROK_BOT_MANUAL_REGISTRATION_REMEDIATION =
|
|
"Grok Bot keeps connectors in the signed-in account and runs them on its hosted computer. Setup does not write that account store, and a data-directory mcp.json is not a registration. In the Grok Bot chat, add a custom MCP server named rea that runs on the Bot's computer with `npx -y rea-agents@<version> mcp`. Do not put credentials in the command or arguments. A stdio server on this machine is not attached.";
|
|
|
|
/** Remediation for a client whose connector is not a local configuration file. */
|
|
export const manualRegistrationRemediation = (
|
|
clientName: string,
|
|
): string | undefined =>
|
|
clientName === "grok_bot"
|
|
? GROK_BOT_MANUAL_REGISTRATION_REMEDIATION
|
|
: undefined;
|
|
|
|
const copilotDirectory = ({ home, env }: ClientPathContext): string =>
|
|
env.COPILOT_HOME ?? join(home, ".copilot");
|
|
|
|
const commandCodeDirectory = ({ home }: ClientPathContext): string =>
|
|
join(home, ".commandcode");
|
|
|
|
const opencodeDirectory = ({ home, env }: ClientPathContext): string =>
|
|
join(env.XDG_CONFIG_HOME ?? join(home, ".config"), "opencode");
|
|
|
|
const existingOpenCodeConfigPath = (context: ClientPathContext): string => {
|
|
if (context.env.OPENCODE_CONFIG !== undefined)
|
|
return context.env.OPENCODE_CONFIG;
|
|
const directory = opencodeDirectory(context);
|
|
const candidates = [
|
|
"opencode.json",
|
|
"opencode.jsonc",
|
|
".opencode.json",
|
|
".opencode.jsonc",
|
|
].map((filename) => join(directory, filename));
|
|
return (
|
|
candidates.find((path) => {
|
|
try {
|
|
lstatSync(path);
|
|
return true;
|
|
} catch (cause: unknown) {
|
|
return !(
|
|
cause instanceof Error &&
|
|
"code" in cause &&
|
|
cause.code === "ENOENT"
|
|
);
|
|
}
|
|
}) ??
|
|
candidates[0] ??
|
|
join(directory, "opencode.json")
|
|
);
|
|
};
|
|
|
|
const devinDirectory = ({ home, platform, env }: ClientPathContext): string =>
|
|
platform === "win32"
|
|
? join(env.APPDATA ?? join(home, "AppData", "Roaming"), "devin")
|
|
: join(home, ".config", "devin");
|
|
|
|
/** Stable product metadata used to derive setup discovery and documentation. */
|
|
export const SUPPORTED_CLIENT_DEFINITIONS = [
|
|
{
|
|
name: "claude_code",
|
|
displayName: "Claude Code",
|
|
configPath: (context: ClientPathContext) =>
|
|
join(claudeCodeConfigDirectory(context), ".claude.json"),
|
|
markerPath: claudeCodeMarkerDirectory,
|
|
format: "json",
|
|
},
|
|
{
|
|
name: "claude_desktop",
|
|
displayName: "Claude Desktop",
|
|
configPath: (context: ClientPathContext) =>
|
|
join(claudeDesktopDirectory(context), "claude_desktop_config.json"),
|
|
markerPath: claudeDesktopDirectory,
|
|
format: "json",
|
|
},
|
|
{
|
|
name: "codex",
|
|
displayName: "Codex",
|
|
configPath: (context: ClientPathContext) =>
|
|
join(codexDirectory(context), "config.toml"),
|
|
markerPath: codexDirectory,
|
|
format: "toml",
|
|
},
|
|
{
|
|
name: "cursor",
|
|
displayName: "Cursor",
|
|
configPath: [".cursor", "mcp.json"],
|
|
markerPath: [".cursor"],
|
|
format: "json",
|
|
},
|
|
{
|
|
name: "gemini_cli",
|
|
displayName: "Gemini CLI",
|
|
configPath: [".gemini", "settings.json"],
|
|
markerPath: [".gemini"],
|
|
format: "json",
|
|
},
|
|
{
|
|
name: "windsurf",
|
|
displayName: "Windsurf",
|
|
configPath: [".codeium", "windsurf", "mcp_config.json"],
|
|
markerPath: [".codeium", "windsurf"],
|
|
format: "json",
|
|
},
|
|
{
|
|
name: "devin",
|
|
displayName: "Devin",
|
|
configPath: ({ home, platform, env }: ClientPathContext) =>
|
|
join(devinDirectory({ home, platform, env }), "mcp_config.json"),
|
|
markerPath: devinDirectory,
|
|
format: "json",
|
|
},
|
|
{
|
|
name: "opencode",
|
|
displayName: "OpenCode",
|
|
configPath: existingOpenCodeConfigPath,
|
|
markerPath: opencodeDirectory,
|
|
format: "opencode",
|
|
},
|
|
{
|
|
name: "antigravity",
|
|
displayName: "Antigravity",
|
|
configPath: [".gemini", "config", "mcp_config.json"],
|
|
markerPath: [".gemini", "config"],
|
|
format: "json",
|
|
},
|
|
{
|
|
name: "copilot_cli",
|
|
displayName: "GitHub Copilot CLI",
|
|
configPath: (context: ClientPathContext) =>
|
|
join(copilotDirectory(context), "mcp-config.json"),
|
|
markerPath: copilotDirectory,
|
|
format: "copilot_cli",
|
|
},
|
|
{
|
|
name: "commandcode",
|
|
displayName: "Command Code",
|
|
configPath: (context: ClientPathContext) =>
|
|
join(commandCodeDirectory(context), "mcp.json"),
|
|
markerPath: commandCodeDirectory,
|
|
format: "commandcode",
|
|
},
|
|
{
|
|
name: "vscode",
|
|
displayName: "VS Code",
|
|
configPath: (context: ClientPathContext) =>
|
|
join(vscodeUserDirectory(context), "mcp.json"),
|
|
markerPath: vscodeUserDirectory,
|
|
format: "vscode",
|
|
},
|
|
{
|
|
name: "grok_build",
|
|
displayName: "Grok Build",
|
|
configPath: (context: ClientPathContext) =>
|
|
join(grokDirectory(context), "config.toml"),
|
|
markerPath: grokDirectory,
|
|
format: "grok",
|
|
},
|
|
{
|
|
name: "grok_bot",
|
|
displayName: "Grok Bot",
|
|
configPath: grokBotDirectory,
|
|
markerPath: grokBotDirectory,
|
|
format: "unsupported",
|
|
},
|
|
] as const satisfies readonly ClientDefinition[];
|
|
|
|
const resolvePath = (path: ClientPath, context: ClientPathContext): string =>
|
|
typeof path === "function" ? path(context) : join(context.home, ...path);
|
|
|
|
/** Describe every client location that setup, doctor, or uninstall may inspect. */
|
|
export const supportedClients = (
|
|
home: string,
|
|
platform: NodeJS.Platform = process.platform,
|
|
env: ClientPathContext["env"] = {
|
|
APPDATA: process.env.APPDATA,
|
|
CLAUDE_CONFIG_DIR: process.env.CLAUDE_CONFIG_DIR,
|
|
CODEX_HOME: process.env.CODEX_HOME,
|
|
COPILOT_HOME: process.env.COPILOT_HOME,
|
|
GROK_HOME: process.env.GROK_HOME,
|
|
OPENCODE_CONFIG: process.env.OPENCODE_CONFIG,
|
|
SAND_DATA_ROOT: process.env.SAND_DATA_ROOT,
|
|
XDG_CONFIG_HOME: process.env.XDG_CONFIG_HOME,
|
|
},
|
|
): readonly SetupClient[] => {
|
|
const context = { home, platform, env };
|
|
return SUPPORTED_CLIENT_DEFINITIONS.map((definition) => ({
|
|
name: definition.name,
|
|
displayName: definition.displayName,
|
|
configPath: resolvePath(definition.configPath, context),
|
|
markerPath: resolvePath(definition.markerPath, context),
|
|
format: definition.format,
|
|
}));
|
|
};
|