From 1be8439294eb2fe5fe87884c9b80acabd93643fe Mon Sep 17 00:00:00 2001 From: Valsecchi Luca Date: Sun, 22 Nov 2026 17:19:46 +0000 Subject: [PATCH] feat(antigravity): Add skills and MCP support Add a Google Antigravity target. Antigravity reads project .agents/skills natively; global skills are linked from ~/.gemini/config/skills. MCP servers are written to .agents/mcp_config.json and ~/.gemini/config/mcp_config.json. Antigravity does not expand ${VAR}, so URLs and headers must be literal and stdio env names are omitted (servers inherit the environment). The file is parsed as JSONC, and per-server settings Antigravity manages (disabled, oauth, tool filters, timeouts) survive sync while the endpoint is unchanged. The target is opt-in for fresh global setups so users who never choose Antigravity keep ${VAR} headers working. Hooks, subagents, and plugins are not generated for Antigravity yet. Co-Authored-By: Claude Opus 5.5 --- README.md | 5 +- docs/public/llms.txt | 8 ++- docs/src/content/docs/cli.mdx | 12 ++++- docs/src/content/docs/index.mdx | 3 +- .../src/cli/commands/install-user.test.ts | 44 +++++++++++++++++ .../dotagents/src/cli/commands/mcp.test.ts | 49 +++++++++++++++++++ .../src/cli/ensure-user-scope.test.ts | 9 ++-- .../dotagents/src/cli/ensure-user-scope.ts | 4 +- packages/dotagents/src/cli/help.ts | 3 ++ .../src/targets/definitions/antigravity.ts | 47 ++++++++++++++++++ packages/dotagents/src/targets/mcp-writer.ts | 31 ++++++++++-- packages/dotagents/src/targets/paths.test.ts | 13 +++++ packages/dotagents/src/targets/paths.ts | 2 + packages/dotagents/src/targets/registry.ts | 3 +- packages/dotagents/src/targets/types.ts | 4 ++ .../dotagents/references/cli-reference.md | 2 +- .../dotagents/references/config-schema.md | 2 +- .../dotagents/references/configuration.md | 1 + specs/SPEC.md | 5 +- 19 files changed, 229 insertions(+), 18 deletions(-) create mode 100644 packages/dotagents/src/targets/definitions/antigravity.ts diff --git a/README.md b/README.md index 1a9e5345..471d15f1 100644 --- a/README.md +++ b/README.md @@ -10,7 +10,7 @@ Shared tooling for coding agents. Declare skills, MCP servers, hooks, subagents, **Shareable.** Skills are directories with a `SKILL.md`. Host them in any git repo, discover them automatically, install with one command. -**Multi-agent.** Configure Claude, Cursor, Codex, GitHub Copilot CLI, Grok, VS Code, OpenCode, and Pi from a single `agents.toml` -- skills, MCP servers, hooks, subagents, and plugins where supported. Pi reads `.agents/skills/` directly. +**Multi-agent.** Configure Claude, Cursor, Codex, GitHub Copilot CLI, Grok, VS Code, OpenCode, Pi, and Google Antigravity from a single `agents.toml` -- skills, MCP servers, hooks, subagents, and plugins where supported. Pi reads `.agents/skills/` directly. ## Quick Start: Global by Default @@ -137,9 +137,12 @@ agents = ["claude", "cursor", "codex", "copilot", "grok", "opencode", "pi"] | `vscode` | `.vscode` | `.vscode/mcp.json` | `.claude/settings.json` | -- | | `opencode` | `.opencode` | `.opencode/opencode.jsonc` | -- | `.opencode/agents/*.md` | | `pi` | `.pi` | `.pi/mcp.json` | -- | -- | +| `antigravity` | `.agents` | `.agents/mcp_config.json` | -- | -- | Pi 0.99+ supports `[[mcp]]` declarations over stdio and Streamable HTTP. With `pi` in `agents`, dotagents writes `.pi/mcp.json` for project scope and `~/.pi/agent/mcp.json` for global scope, or `$PI_CODING_AGENT_DIR/mcp.json` when overridden (`~` is expanded). Existing unrelated servers and top-level settings are preserved. Pi server names allow only letters, digits, underscores, and hyphens. URLs must be literal; `${VAR}` references work in headers and environment values. Pi only reads project MCP config after the project is trusted; use `pi mcp list --json` to check connections and `pi mcp login ` for OAuth. Plugin-bundled MCP is not projected to Pi yet. +Google Antigravity reads `.agents/skills/` natively in project scope; for global scope dotagents links `~/.gemini/config/skills` to `~/.agents/skills`. With `antigravity` in `agents`, dotagents writes MCP servers to `.agents/mcp_config.json` for project scope and `~/.gemini/config/mcp_config.json` for global scope over stdio and Streamable HTTP. Existing unrelated servers, comments, and settings are preserved, including per-server settings Antigravity manages such as `disabled`, `enabledTools`, `disabledTools`, `tools`, `timeoutSeconds`, and `oauth`. Server names allow only letters, digits, underscores, and hyphens. Antigravity does not expand `${VAR}` references, so URLs and header values must be literal; stdio servers inherit Antigravity's environment, so `env` names are not written and those variables must be set where Antigravity runs. A fresh global setup does not select `antigravity`; add it to `agents` explicitly. Hooks, subagents, and plugins are not generated for Antigravity yet. + Custom subagents are declared with `[[subagents]]` entries. dotagents writes generated runtime-specific files during `install` and repairs them during `sync`: ```toml diff --git a/docs/public/llms.txt b/docs/public/llms.txt index c9fe82b8..80b1e38f 100644 --- a/docs/public/llms.txt +++ b/docs/public/llms.txt @@ -2,7 +2,7 @@ > Shared tooling for coding agents -dotagents manages agent skills, MCP servers, hooks, subagents, and plugins declared in `agents.toml`, and handles symlinks and config generation so tools like Claude Code, Cursor, Codex, GitHub Copilot CLI, Grok, VS Code, OpenCode, and Pi are configured from a single source of truth. +dotagents manages agent skills, MCP servers, hooks, subagents, and plugins declared in `agents.toml`, and handles symlinks and config generation so tools like Claude Code, Cursor, Codex, GitHub Copilot CLI, Grok, VS Code, OpenCode, Pi, and Google Antigravity are configured from a single source of truth. Install: `npm install -g @sentry/dotagents` Run without installing: `npx @sentry/dotagents ` @@ -158,7 +158,7 @@ targets = ["claude", "cursor", "codex", "copilot", "grok", "opencode", "pi"] |-------|------|----------|---------|-------------| | `version` | integer | Yes | -- | Schema version. Always `1`. | | `defaultRepositorySource` | string | No | `github` | Host used for shorthand `owner/repo` skill sources. Valid values: `github`, `gitlab`. | -| `agents` | string[] | No | `[]` | Agent tool IDs: `claude`, `cursor`, `codex`, `copilot`, `grok`, `vscode`, `opencode`, `pi`. Creates symlinks and config files for each where supported. `grok` is a plugin-only target. | +| `agents` | string[] | No | `[]` | Agent tool IDs: `claude`, `cursor`, `codex`, `copilot`, `grok`, `vscode`, `opencode`, `pi`, `antigravity`. Creates symlinks and config files for each where supported. `grok` is a plugin-only target. | | `subagents` | table[] | No | `[]` | Custom subagent declarations. Generates runtime-specific files for Claude, Cursor, Codex, and OpenCode. | | `plugins` | table[] | No | `[]` | Plugin declarations. Installs canonical bundles into `.agents/plugins/` and generates runtime plugin outputs for Claude, Cursor, Codex, Copilot, Grok, OpenCode, and Pi skill projection where supported. | | `minimum_release_age` | integer | No | -- | Minimum commit age, in minutes, before a git skill, subagent, or plugin can install. | @@ -217,6 +217,7 @@ Config files generated per agent: - Claude: `.mcp.json` (JSON) - Cursor: `.cursor/mcp.json` (JSON) - Pi: `.pi/mcp.json` (JSON); requires Pi 0.99 or later +- Google Antigravity: `.agents/mcp_config.json` (JSON, shared) - Codex: `.codex/config.toml` (TOML, shared with other Codex config) - VS Code: `.vscode/mcp.json` (JSON) - OpenCode: `.opencode/opencode.jsonc` by default (JSONC, shared). Existing `.opencode/opencode.json`, `opencode.jsonc`, or `opencode.json` files are reused in precedence order. @@ -226,6 +227,8 @@ Copilot accepts both bare server maps and `mcpServers` documents. Global MCP use Pi 0.99+ supports `[[mcp]]` declarations over stdio and Streamable HTTP. With `pi` in `agents`, dotagents writes `.pi/mcp.json` for project scope and `~/.pi/agent/mcp.json` for global scope, or `$PI_CODING_AGENT_DIR/mcp.json` when overridden (`~` is expanded). Existing unrelated servers and top-level settings are preserved. Pi server names allow only letters, digits, underscores, and hyphens. URLs must be literal; `${VAR}` references work in headers and environment values. Pi only reads project MCP config after the project is trusted; use `pi mcp list --json` to check connections and `pi mcp login ` for OAuth. Plugin-bundled MCP is not projected to Pi yet. +Google Antigravity reads `.agents/skills/` natively in project scope; for global scope dotagents links `~/.gemini/config/skills` to `~/.agents/skills`. With `antigravity` in `agents`, dotagents writes MCP servers to `.agents/mcp_config.json` for project scope and `~/.gemini/config/mcp_config.json` for global scope over stdio and Streamable HTTP. Existing unrelated servers, comments, and settings are preserved, including per-server settings Antigravity manages such as `disabled`, `enabledTools`, `disabledTools`, `tools`, `timeoutSeconds`, and `oauth`. Server names allow only letters, digits, underscores, and hyphens. Antigravity does not expand `${VAR}` references, so URLs and header values must be literal; stdio servers inherit Antigravity's environment, so `env` names are not written and those variables must be set where Antigravity runs. A fresh global setup does not select `antigravity`; add it to `agents` explicitly. Hooks, subagents, and plugins are not generated for Antigravity yet. + ### Hooks Each `[[hooks]]` entry requires `event` and `command`. Optional: `matcher` to filter by tool name. @@ -522,6 +525,7 @@ Check selected-scope health: gitignore setup where applicable, installed skills | `vscode` | VS Code Copilot | `.vscode` | (reads `.agents/skills/` natively) | `.vscode/mcp.json` | `.claude/settings.json` | Not supported | | `opencode` | OpenCode | `.opencode` | (reads `.agents/skills/` natively) | `.opencode/opencode.jsonc` by default | Not supported | `.opencode/agents/*.md` | | `pi` | Pi | `.pi` | (reads `.agents/skills/` natively) | `.pi/mcp.json` | Not supported | Not supported | +| `antigravity` | Google Antigravity | `.agents` | Project: reads `.agents/skills/`; global: `~/.gemini/config/skills/` symlink | `.agents/mcp_config.json` | Not supported | Not supported | Claude uses `.claude/skills/`, and Cursor shares the same Claude-compatible skills symlink. Codex, VS Code, and OpenCode read `.agents/skills/` directly. diff --git a/docs/src/content/docs/cli.mdx b/docs/src/content/docs/cli.mdx index 4abf136e..0607bef7 100644 --- a/docs/src/content/docs/cli.mdx +++ b/docs/src/content/docs/cli.mdx @@ -387,7 +387,7 @@ Status output: | Field | Type | Default | Description | | --- | --- | --- | --- | | `version` | integer | -- | Schema version. Always `1`. | -| `agents` | string[] | `[]` | Agent targets: `claude`, `cursor`, `codex`, `copilot`, `grok`, `vscode`, `opencode`, `pi`. `grok` is a plugin-only target. | +| `agents` | string[] | `[]` | Agent targets: `claude`, `cursor`, `codex`, `copilot`, `grok`, `vscode`, `opencode`, `pi`, `antigravity`. `grok` is a plugin-only target. | | `subagents` | table[] | `[]` | Custom subagent declarations for Claude, Cursor, Codex, and OpenCode | | `plugins` | table[] | `[]` | Plugin declarations for Claude, Cursor, Codex, Copilot, Grok, OpenCode, and Pi. | | `minimum_release_age` | integer | -- | Minimum commit age, in minutes, before a git skill, subagent, or plugin can install. | @@ -429,6 +429,16 @@ Pi reads project MCP config only after the project is trusted. Check connections with `pi mcp list --json` and sign in with `pi mcp login ` for OAuth. Plugin-bundled MCP is not projected to Pi yet. +Google Antigravity uses `.agents/mcp_config.json` in project scope and +`~/.gemini/config/mcp_config.json` globally. Existing unrelated servers, +comments, and settings are preserved, including per-server settings +Antigravity manages such as `disabled`. Server names allow letters, digits, +underscores, and hyphens. Antigravity does not expand `${VAR}` references, so +URLs and header values must be literal. Stdio servers inherit Antigravity's +environment, so `env` names are not written and those variables must be set +where Antigravity runs. A fresh global setup does not select `antigravity`; +add it to `agents` explicitly. + ### Hooks | Field | Type | Required | Description | diff --git a/docs/src/content/docs/index.mdx b/docs/src/content/docs/index.mdx index 33d3ed09..5cdddb39 100644 --- a/docs/src/content/docs/index.mdx +++ b/docs/src/content/docs/index.mdx @@ -97,7 +97,7 @@ targets = ["claude", "cursor", "codex", "copilot", "opencode"]`}

Supported Agents

-

The `agents` array tells dotagents which tools to configure. Grok is a plugin-only target. Pi supports MCP and reads `.agents/skills/` directly.

+

The `agents` array tells dotagents which tools to configure. Grok is a plugin-only target. Pi and Google Antigravity support MCP and read `.agents/skills/` directly.

| Agent | Config Dir | MCP Config | Hooks | Subagents | @@ -109,6 +109,7 @@ targets = ["claude", "cursor", "codex", "copilot", "opencode"]`} | `vscode` | `.vscode` | `.vscode/mcp.json` | `.claude/settings.json` | None | | `opencode` | `.opencode` | `.opencode/opencode.jsonc` | None | `.opencode/agents/*.md` | | `pi` | `.pi` | `.pi/mcp.json` (Pi 0.99+) | None | None | + | `antigravity` | `.agents` | `.agents/mcp_config.json` | None | None | OpenCode reuses existing project config from `.opencode/opencode.jsonc`, `.opencode/opencode.json`, `opencode.jsonc`, or `opencode.json`, in that order. New projects use `.opencode/opencode.jsonc`.
diff --git a/packages/dotagents/src/cli/commands/install-user.test.ts b/packages/dotagents/src/cli/commands/install-user.test.ts index a75812bf..32218188 100644 --- a/packages/dotagents/src/cli/commands/install-user.test.ts +++ b/packages/dotagents/src/cli/commands/install-user.test.ts @@ -154,4 +154,48 @@ source = "path:skill-source/pdf" const lockfile = await loadLockfile(scope.lockPath); expect(lockfile!.skills["pdf"]).toEqual({ source: "path:skill-source/pdf" }); }); + + it("links Antigravity global skills and merges its global MCP config", async () => { + tmpDir = await mkdtemp(join(tmpdir(), "dotagents-user-install-")); + const homeDir = join(tmpDir, "home"); + const geminiConfig = join(homeDir, ".gemini", "config"); + process.env["HOME"] = homeDir; + process.env["DOTAGENTS_HOME"] = join(tmpDir, "agents"); + process.env["DOTAGENTS_STATE_DIR"] = join(tmpDir, "state"); + vi.resetModules(); + + const [{ runInstall }, { resolveScope }] = await Promise.all([ + import("./install.js"), + import("../../scope.js"), + ]); + + await mkdir(geminiConfig, { recursive: true }); + const manual = { serverUrl: "https://manual.example/mcp", oauth: { clientId: "manual" } }; + await writeFile(join(geminiConfig, "mcp_config.json"), JSON.stringify({ mcpServers: { manual } })); + const scope = resolveScope("user"); + await mkdir(scope.root, { recursive: true }); + await writeFile( + scope.configPath, + `version = 1 +agents = ["antigravity"] + +[[mcp]] +name = "fixture" +command = "node" +args = ["server.js"] +`, + ); + + await runInstall({ scope }); + + const skillsLink = join(geminiConfig, "skills"); + expect((await lstat(skillsLink)).isSymbolicLink()).toBe(true); + expect(await readlink(skillsLink)).toBe(relative(geminiConfig, scope.skillsDir)); + expect(JSON.parse(await readFile(join(geminiConfig, "mcp_config.json"), "utf-8"))).toEqual({ + mcpServers: { + manual, + fixture: { command: "node", args: ["server.js"] }, + }, + }); + }); }); diff --git a/packages/dotagents/src/cli/commands/mcp.test.ts b/packages/dotagents/src/cli/commands/mcp.test.ts index 29e20bf3..bcdd2785 100644 --- a/packages/dotagents/src/cli/commands/mcp.test.ts +++ b/packages/dotagents/src/cli/commands/mcp.test.ts @@ -7,6 +7,7 @@ import { loadConfig } from "../../config/loader.js"; import { resolveScope, type ScopeRoot } from "../../scope.js"; import { runSync } from "./sync.js"; import { runInstall } from "./install.js"; +import { parse as parseJsonc } from "jsonc-parser"; describe("mcp", () => { let tmpDir: string; @@ -127,6 +128,54 @@ describe("mcp", () => { expect(await readFile(scope.configPath, "utf-8")).toBe(config); }); + it("installs and repairs Antigravity MCP in .agents/mcp_config.json while preserving unrelated settings", async () => { + await writeFile(scope.configPath, 'version = 1\nagents = ["antigravity"]\n'); + const targetPath = join(projectRoot, ".agents", "mcp_config.json"); + const manual = { command: "manual-server", disabled: true, timeoutSeconds: 30 }; + await writeFile(targetPath, `{\n // Added by hand\n "mcpServers": { "manual": ${JSON.stringify(manual)}, },\n}\n`); + + await runMcpAdd({ scope, name: "local-tools", command: "node", args: ["server.mjs"], env: ["TOOLS_TOKEN"] }); + await runMcpAdd({ scope, name: "remote_tools", url: "https://example.com/mcp", headers: ["X-Team:docs"] }); + const expected = { + mcpServers: { + manual, + "local-tools": { command: "node", args: ["server.mjs"] }, + remote_tools: { url: "https://example.com/mcp", headers: { "X-Team": "docs" } }, + }, + }; + const written = await readFile(targetPath, "utf-8"); + expect(written).toContain("// Added by hand"); + expect(parseJsonc(written)).toEqual(expected); + + // Settings changed in Antigravity survive sync without counting as drift. + const disabled = { ...expected.mcpServers["local-tools"], disabled: true, disabledTools: ["write"] }; + await writeFile(targetPath, JSON.stringify({ mcpServers: { ...expected.mcpServers, "local-tools": disabled } })); + expect((await runSync({ scope })).mcpRepaired).toBe(0); + + await writeFile(targetPath, JSON.stringify({ mcpServers: { manual, "local-tools": { ...disabled, args: ["old.mjs"] } } })); + expect((await runSync({ scope })).mcpRepaired).toBe(1); + expect(JSON.parse(await readFile(targetPath, "utf-8"))).toEqual({ + mcpServers: { ...expected.mcpServers, "local-tools": disabled }, + }); + + // Credentials for an old endpoint must not follow the server to a new URL. + const oldRemote = { serverUrl: "https://old.example/mcp", oauth: { clientId: "old" }, disabled: true }; + await writeFile(targetPath, JSON.stringify({ mcpServers: { ...expected.mcpServers, remote_tools: oldRemote } })); + expect((await runSync({ scope })).mcpRepaired).toBe(1); + expect(JSON.parse(await readFile(targetPath, "utf-8")).mcpServers.remote_tools).toEqual(expected.mcpServers.remote_tools); + }); + + it.each([ + { name: "server.v2", url: "https://example.com/mcp", headers: undefined, error: "Invalid Antigravity MCP server name" }, + { name: "remote", url: "https://${HOST}/mcp", headers: undefined, error: "does not expand" }, + { name: "remote", url: "https://example.com/mcp", headers: ["Authorization:Bearer ${API_TOKEN}"], error: "does not expand" }, + ])("rejects unsupported Antigravity declarations before saving: $name / $url", async ({ name, url, headers, error }) => { + const config = 'version = 1\nagents = ["antigravity"]\n'; + await writeFile(scope.configPath, config); + await expect(runMcpAdd({ scope, name, url, headers })).rejects.toThrow(error); + expect(await readFile(scope.configPath, "utf-8")).toBe(config); + }); + it("adds a stdio server", async () => { await runMcpAdd({ scope, diff --git a/packages/dotagents/src/cli/ensure-user-scope.test.ts b/packages/dotagents/src/cli/ensure-user-scope.test.ts index 71850ae3..d2fd2e20 100644 --- a/packages/dotagents/src/cli/ensure-user-scope.test.ts +++ b/packages/dotagents/src/cli/ensure-user-scope.test.ts @@ -4,7 +4,7 @@ import { readFile, rm, mkdtemp } from "node:fs/promises"; import { join } from "node:path"; import { tmpdir } from "node:os"; import { ensureUserScopeBootstrapped } from "./ensure-user-scope.js"; -import { allAgentIds } from "../targets/registry.js"; +import { allAgents } from "../targets/registry.js"; import type { ScopeRoot } from "../scope.js"; function userScope(home: string): ScopeRoot { @@ -42,10 +42,11 @@ describe("ensureUserScopeBootstrapped", () => { const content = await readFile(scope.configPath, "utf-8"); expect(content).toContain("version = 1"); - // Should include all known agents - for (const id of allAgentIds()) { - expect(content).toContain(`"${id}"`); + // Should include every agent except opt-in targets + for (const agent of allAgents()) { + expect(content.includes(`"${agent.id}"`)).toBe(!agent.optIn); } + expect(content).not.toContain('"antigravity"'); expect(console.error).toHaveBeenCalledWith( expect.stringContaining("Initialized"), ); diff --git a/packages/dotagents/src/cli/ensure-user-scope.ts b/packages/dotagents/src/cli/ensure-user-scope.ts index e5eddf27..228b5e58 100644 --- a/packages/dotagents/src/cli/ensure-user-scope.ts +++ b/packages/dotagents/src/cli/ensure-user-scope.ts @@ -2,7 +2,7 @@ import { existsSync } from "node:fs"; import { mkdir, writeFile } from "node:fs/promises"; import chalk from "chalk"; import { generateDefaultConfig } from "../config/writer.js"; -import { allAgentIds } from "../targets/registry.js"; +import { allAgents } from "../targets/registry.js"; import type { ScopeRoot } from "../scope.js"; /** @@ -19,7 +19,7 @@ export async function ensureUserScopeBootstrapped(scope: ScopeRoot): Promise !agent.optIn).map((agent) => agent.id) }), "utf-8", ); console.error(chalk.dim("Initialized ~/.agents/agents.toml")); diff --git a/packages/dotagents/src/cli/help.ts b/packages/dotagents/src/cli/help.ts index 720a21fd..b55353cb 100644 --- a/packages/dotagents/src/cli/help.ts +++ b/packages/dotagents/src/cli/help.ts @@ -62,6 +62,7 @@ Options: Manage MCP server declarations. Pi 0.99+ uses .pi/mcp.json (project) or ~/.pi/agent/mcp.json (global). PI_CODING_AGENT_DIR overrides Pi's global config directory. +Antigravity uses .agents/mcp_config.json (project) or ~/.gemini/config/mcp_config.json (global). Subcommands: add Add an MCP server declaration @@ -73,6 +74,8 @@ Run 'npx @sentry/dotagents mcp --help' for details.`, Add an MCP server declaration to agents.toml. Pi server names allow letters, digits, underscores, and hyphens; URLs must be literal. +Antigravity server names follow the same rule; URLs and header values must be literal. +Antigravity stdio servers inherit its environment; --env names are not written. Options: --command Stdio command including arguments diff --git a/packages/dotagents/src/targets/definitions/antigravity.ts b/packages/dotagents/src/targets/definitions/antigravity.ts new file mode 100644 index 00000000..f7b56d6c --- /dev/null +++ b/packages/dotagents/src/targets/definitions/antigravity.ts @@ -0,0 +1,47 @@ +import { homedir } from "node:os"; +import { join } from "node:path"; +import type { AgentDefinition } from "../types.js"; +import { UnsupportedFeature } from "../errors.js"; + +const antigravity: AgentDefinition = { + id: "antigravity", + displayName: "Google Antigravity", + configDir: ".agents", + // Rejects ${VAR} headers, so a fresh global setup must not select it implicitly. + optIn: true, + // Reads project .agents/skills/ natively. Global discovery uses ~/.gemini/config/skills/. + skillsParentDir: undefined, + userSkillsParentDirs: [join(homedir(), ".gemini", "config")], + mcp: { + filePath: ".agents/mcp_config.json", + rootKey: "mcpServers", + format: "jsonc", + shared: true, + // Settings users change in Antigravity itself, such as disabling a server. + clientFields: ["disabled", "enabledTools", "disabledTools", "tools", "timeoutSeconds", "oauth", "authProviderType"], + }, + serializeServer(server) { + if (!/^[A-Za-z0-9_-]+$/.test(server.name)) { + throw new Error(`Invalid Antigravity MCP server name "${server.name}". Use only letters, digits, underscores, and hyphens.`); + } + if (server.url) { + const values = [server.url, ...Object.values(server.headers ?? {})]; + if (server.interpolateEnvRefs !== false && values.some((value) => value.includes("${"))) { + throw new Error(`Antigravity MCP server "${server.name}" requires a literal URL and header values. Antigravity does not expand \${VAR} references.`); + } + return [server.name, { url: server.url, ...(server.headers && { headers: server.headers }) }]; + } + // Stdio servers inherit Antigravity's environment, so declared env names need no entry. + return [server.name, { + command: server.command, + args: server.args ?? [], + ...(server.cwd && { cwd: server.cwd }), + ...(server.envValues && { env: server.envValues }), + }]; + }, + serializeHooks() { + throw new UnsupportedFeature("antigravity", "hooks"); + }, +}; + +export default antigravity; diff --git a/packages/dotagents/src/targets/mcp-writer.ts b/packages/dotagents/src/targets/mcp-writer.ts index 8e2ee911..2d1bda33 100644 --- a/packages/dotagents/src/targets/mcp-writer.ts +++ b/packages/dotagents/src/targets/mcp-writer.ts @@ -242,7 +242,8 @@ export async function reconcileMcpConfigs( continue; } - const targetIssues = desiredIssues(id, filePath, existingRoot.servers, expectedServers); + const fileServers = keepClientFields(expectedServers, existingRoot.servers, mcp.clientFields); + const targetIssues = desiredIssues(id, filePath, existingRoot.servers, fileServers); issues.push(...targetIssues); const envelopeIssue = existingRoot.bare && pathFormat.requiresRoot ? { @@ -257,11 +258,11 @@ export async function reconcileMcpConfigs( existing, mcp.rootKey, existingRoot, - expectedServers, + fileServers, !pathFormat.requiresRoot, ); if (contentChanged) { - await writeReconciledDocument(filePath, mcp, next, expectedServers, target.mode); + await writeReconciledDocument(filePath, mcp, next, fileServers, target.mode); } await enforceMode(filePath, mcp, next, modeCheck, target.mode); written.push(filePath); @@ -451,6 +452,30 @@ function renderServers( return Object.fromEntries(servers.map(serializeServer)); } +/** + * Carry client-owned settings from existing entries into the rendered servers. + * Settings such as OAuth belong to one endpoint, so a changed command or URL drops them. + */ +function keepClientFields( + expected: SerializedObject, + existing: SerializedObject, + fields: string[] | undefined, +): SerializedObject { + if (!fields) {return expected;} + return Object.fromEntries(Object.entries(expected).map(([name, server]) => { + const current = existing[name]; + if (!isSerializedObject(current) || !isSerializedObject(server)) {return [name, server];} + const sameEndpoint = current["command"] === server["command"] && + (current["url"] ?? current["serverUrl"]) === server["url"]; + if (!sameEndpoint) {return [name, server];} + const merged: SerializedObject = Object.assign({}, server); + for (const field of fields) { + if (field in current) {merged[field] = current[field]!;} + } + return [name, merged]; + })); +} + function desiredIssues( agent: string, filePath: string, diff --git a/packages/dotagents/src/targets/paths.test.ts b/packages/dotagents/src/targets/paths.test.ts index aae6bb8f..ed6de545 100644 --- a/packages/dotagents/src/targets/paths.test.ts +++ b/packages/dotagents/src/targets/paths.test.ts @@ -87,6 +87,13 @@ describe("getUserMcpTarget", () => { } }); + it("antigravity uses the shared global config directory", () => { + expect(getUserMcpTarget("antigravity")).toEqual({ + filePath: join(home, ".gemini", "config", "mcp_config.json"), + shared: true, + }); + }); + it("throws for unknown agent", () => { expect(() => getUserMcpTarget("emacs")).toThrow("Unknown agent"); }); @@ -123,6 +130,12 @@ describe("skill discovery paths", () => { expect(agent.userSkillsParentDirs).toEqual([join(home, ".claude")]); }); + it("antigravity reads project skills natively and needs a global symlink", () => { + const agent = getAgent("antigravity")!; + expect(agent.skillsParentDir).toBeUndefined(); + expect(agent.userSkillsParentDirs).toEqual([join(home, ".gemini", "config")]); + }); + // Agents that DO read .agents/skills/ natively need no symlinks it("vscode reads .agents/skills/ natively", () => { const agent = getAgent("vscode")!; diff --git a/packages/dotagents/src/targets/paths.ts b/packages/dotagents/src/targets/paths.ts index 64ac0121..5e5ca644 100644 --- a/packages/dotagents/src/targets/paths.ts +++ b/packages/dotagents/src/targets/paths.ts @@ -42,6 +42,8 @@ export function getUserMcpTarget(agentId: string): UserMcpTarget { : configuredDir; return { filePath: join(agentDir, "mcp.json"), shared: true }; } + case "antigravity": + return { filePath: join(home, ".gemini", "config", "mcp_config.json"), shared: true }; default: throw new Error(`Unknown agent for user-scope MCP: ${agentId}`); } diff --git a/packages/dotagents/src/targets/registry.ts b/packages/dotagents/src/targets/registry.ts index dbcf0099..75afda62 100644 --- a/packages/dotagents/src/targets/registry.ts +++ b/packages/dotagents/src/targets/registry.ts @@ -6,8 +6,9 @@ import vscode from "./definitions/vscode.js"; import opencode from "./definitions/opencode.js"; import copilot from "./definitions/copilot.js"; import pi from "./definitions/pi.js"; +import antigravity from "./definitions/antigravity.js"; -const ALL_AGENTS: AgentDefinition[] = [claude, cursor, codex, vscode, opencode, copilot, pi]; +const ALL_AGENTS: AgentDefinition[] = [claude, cursor, codex, vscode, opencode, copilot, pi, antigravity]; const AGENT_REGISTRY = new Map( ALL_AGENTS.map((a) => [a.id, a]), diff --git a/packages/dotagents/src/targets/types.ts b/packages/dotagents/src/targets/types.ts index 278fe2a2..648bdf64 100644 --- a/packages/dotagents/src/targets/types.ts +++ b/packages/dotagents/src/targets/types.ts @@ -68,6 +68,8 @@ export interface McpConfigSpec { * undeclared MCP servers are preserved for every target. */ shared: boolean; + /** Per-server settings the client edits itself; existing values survive sync. */ + clientFields?: string[]; } /** @@ -138,4 +140,6 @@ export interface AgentDefinition { serializeHooks: HookSerializer; /** Subagent config specification (undefined if agent doesn't support custom subagents) */ subagents?: SubagentConfigSpec; + /** Left out of the default global agent list because it restricts shared declarations. */ + optIn?: boolean; } diff --git a/plugins/dotagents/skills/dotagents/references/cli-reference.md b/plugins/dotagents/skills/dotagents/references/cli-reference.md index c1a4ce19..cc4c2456 100644 --- a/plugins/dotagents/skills/dotagents/references/cli-reference.md +++ b/plugins/dotagents/skills/dotagents/references/cli-reference.md @@ -43,7 +43,7 @@ npx @sentry/dotagents --project init | Flag | Description | |------|-------------| -| `--agents ` | Comma-separated agent targets (claude, cursor, codex, copilot, vscode, grok, opencode, pi) | +| `--agents ` | Comma-separated agent targets (claude, cursor, codex, copilot, vscode, grok, opencode, pi, antigravity) | | `--force` | Overwrite existing `agents.toml` | **Interactive mode** (when TTY is available): diff --git a/plugins/dotagents/skills/dotagents/references/config-schema.md b/plugins/dotagents/skills/dotagents/references/config-schema.md index 91f4711e..b1aaa375 100644 --- a/plugins/dotagents/skills/dotagents/references/config-schema.md +++ b/plugins/dotagents/skills/dotagents/references/config-schema.md @@ -24,7 +24,7 @@ minimum_release_age_exclude = ["getsentry/*"] # Optional |-------|------|----------|---------|-------------| | `version` | integer | Yes | -- | Schema version, must be `1` | | `defaultRepositorySource` | string | No | `github` | Host for shorthand `owner/repo` sources. Valid values: `github`, `gitlab` | -| `agents` | string[] | No | `[]` | Agent targets: `claude`, `cursor`, `codex`, `copilot`, `vscode`, `grok`, `opencode`, `pi` | +| `agents` | string[] | No | `[]` | Agent targets: `claude`, `cursor`, `codex`, `copilot`, `vscode`, `grok`, `opencode`, `pi`, `antigravity` | | `minimum_release_age` | integer | No | -- | Minimum commit age, in minutes, before a git skill, subagent, or plugin can install | | `minimum_release_age_exclude` | string[] | No | `[]` | Sources that bypass `minimum_release_age` | diff --git a/plugins/dotagents/skills/dotagents/references/configuration.md b/plugins/dotagents/skills/dotagents/references/configuration.md index b87f8abb..74665930 100644 --- a/plugins/dotagents/skills/dotagents/references/configuration.md +++ b/plugins/dotagents/skills/dotagents/references/configuration.md @@ -105,6 +105,7 @@ MCP configs are written per-agent in the appropriate format: - VS Code: `.vscode/mcp.json` (JSON) - OpenCode: `.opencode/opencode.jsonc` by default (JSONC, shared); existing nested or root OpenCode config files are reused. - GitHub Copilot: `.mcp.json` or an existing `.github/mcp.json`; global scope uses `$COPILOT_HOME/mcp-config.json` (default `~/.copilot/mcp-config.json`). +- Google Antigravity: `.agents/mcp_config.json`; global scope uses `~/.gemini/config/mcp_config.json`. URLs and headers must be literal. Stdio servers inherit the environment that launches Antigravity, so `env` names are not written; set those variables there. ## Hooks diff --git a/specs/SPEC.md b/specs/SPEC.md index 3ae78181..df07282d 100644 --- a/specs/SPEC.md +++ b/specs/SPEC.md @@ -93,7 +93,7 @@ targets = ["claude", "cursor", "codex", "copilot", "grok", "opencode", "pi"] |-------|----------|-------------| | `version` | Yes | Schema version. Always `1`. | | `defaultRepositorySource` | No | Host used for shorthand `owner/repo` skill sources. Valid values: `github`, `gitlab`. Defaults to `github`. | -| `agents` | No | Array of agent tool IDs. Valid: `claude`, `cursor`, `codex`, `copilot`, `vscode`, `grok`, `opencode`, `pi`. Defaults to `[]`. When set, dotagents creates skills symlinks and runtime config files for each agent where supported. `grok` is a plugin-only target. | +| `agents` | No | Array of agent tool IDs. Valid: `claude`, `cursor`, `codex`, `copilot`, `vscode`, `grok`, `opencode`, `pi`, `antigravity`. Defaults to `[]`. When set, dotagents creates skills symlinks and runtime config files for each agent where supported. `grok` is a plugin-only target. | | `project` | No | Project metadata. | | `symlinks` | No | Symlink configuration (legacy — prefer `agents` for new projects). | | `skills` | No | Skill dependencies (array of tables). | @@ -289,9 +289,12 @@ Global scope installs canonical plugins into `~/.agents/plugins//`. It gen | `vscode` | VS Code Copilot | `.vscode` | `.vscode/mcp.json` | JSON | Not supported | | `opencode` | OpenCode | `.opencode` | `.opencode/opencode.jsonc` | JSONC (shared) | `.opencode/agents/*.md` | | `pi` | Pi | `.pi` | `.pi/mcp.json` | JSON (shared) | Not supported | +| `antigravity` | Google Antigravity | `.agents` | `.agents/mcp_config.json` | JSON (shared) | Not supported | Pi 0.99+ supports `[[mcp]]` declarations over stdio and Streamable HTTP. With `pi` in `agents`, dotagents writes `.pi/mcp.json` for project scope and `~/.pi/agent/mcp.json` for global scope, or `$PI_CODING_AGENT_DIR/mcp.json` when overridden (`~` is expanded). Existing unrelated servers and top-level settings are preserved. Pi server names allow only letters, digits, underscores, and hyphens. URLs must be literal; `${VAR}` references work in headers and environment values. Pi only reads project MCP config after the project is trusted; use `pi mcp list --json` to check connections and `pi mcp login ` for OAuth. Plugin-bundled MCP is not projected to Pi yet. +Google Antigravity reads `.agents/skills/` natively in project scope; for global scope dotagents links `~/.gemini/config/skills` to `~/.agents/skills`. With `antigravity` in `agents`, dotagents writes MCP servers to `.agents/mcp_config.json` for project scope and `~/.gemini/config/mcp_config.json` for global scope over stdio and Streamable HTTP. Existing unrelated servers, comments, and settings are preserved, including per-server settings Antigravity manages such as `disabled`, `enabledTools`, `disabledTools`, `tools`, `timeoutSeconds`, and `oauth`. Server names allow only letters, digits, underscores, and hyphens. Antigravity does not expand `${VAR}` references, so URLs and header values must be literal; stdio servers inherit Antigravity's environment, so `env` names are not written and those variables must be set where Antigravity runs. A fresh global setup does not select `antigravity`; add it to `agents` explicitly. Hooks, subagents, and plugins are not generated for Antigravity yet. + Each agent has its own MCP config format. dotagents translates the universal `[[mcp]]` declarations into the format each tool expects during `install` and `sync`. Grok is currently supported for plugin projections only. Copilot reads project skills from `.agents/skills/` and links global skills into