Skip to content

armgit / agtx

Public Imported from GitHub
0

πŸ„πŸΌβ€β™‚οΈ The blackboard for coding agents - agentic development environment for claude code, codex, cursor, opencode, grok and more.

feat: add antigravity (#136)

Fynn Fluegge02caff96afef
diff --git a/CLAUDE.md b/CLAUDE.md
index 793c26a..5c106f2 100644
--- a/CLAUDE.md
+++ b/CLAUDE.md
@@ -1,6 +1,6 @@
# AGTX - Terminal Kanban for Coding Agents
-A terminal-native kanban board for managing multiple coding agent sessions (Claude Code, Codex, Gemini, Copilot, OpenCode, Cursor, Grok) with isolated git worktrees.
+A terminal-native kanban board for managing multiple coding agent sessions (Claude Code, Codex, Gemini, Copilot, OpenCode, Cursor, Grok, Antigravity) with isolated git worktrees.
## Quick Start
@@ -163,6 +163,7 @@ Skills are markdown files with YAML frontmatter deployed to agent-native discove
- Codex: `.codex/skills/agtx-plan/SKILL.md`
- Cursor: `.cursor/skills/agtx-plan/SKILL.md`
- Grok: `.grok/skills/agtx-plan/SKILL.md`
+- Antigravity: `.agents/skills/agtx-plan/SKILL.md` (vendor-neutral tree, not an agent dotdir)
- OpenCode: `.opencode/command/agtx-plan.md` (frontmatter stripped)
- Copilot: `.github/agents/agtx/plan.md`
@@ -177,13 +178,19 @@ Canonical copy always at `.agtx/skills/agtx-plan/SKILL.md`.
| gemini | `.gemini/settings.json` | JSON, `mcpServers` + `trust: true` |
| cursor | `.cursor/mcp.json` | JSON, `mcpServers` |
| grok | `.grok/config.toml` | TOML, `[mcp_servers.agtx]` |
+| antigravity | `.agents/mcp_config.json` | JSON, `mcpServers` |
| opencode | opencode config | JSON, `mcp` |
-Two agents need an extra trust side-effect to avoid an interactive dialog on first open: Claude gets `.claude/settings.local.json` with `enableAllProjectMcpServers: true`, and Codex gets a `[projects."<worktree>"] trust_level = "trusted"` entry appended to the user's global `~/.codex/config.toml`.
+Two writers **merge** instead of overwriting, because their file may already be tracked in the repo: grok appends `[mcp_servers.agtx]` to any existing `.grok/config.toml`, and antigravity parses `.agents/mcp_config.json`, inserts `mcpServers.agtx`, and writes it back β€” preserving other servers and top-level sibling keys. (`.agents/` is vendor-neutral, so a project is more likely to ship one.)
+
+Two agents need an extra trust side-effect to avoid an interactive dialog on first open: Claude gets `.claude/settings.local.json` with `enableAllProjectMcpServers: true`, and Codex gets a `[projects."<worktree>"] trust_level = "trusted"` entry appended to the user's global `~/.codex/config.toml`. Both writes resolve the home directory through `agent_trust_home()`, which honours `AGTX_AGENT_HOME` so the test suite does not append temp-dir trust entries to the real user's config.
+
+### MCP pre-handshake filter
+`agtx mcp-serve` does not hand raw stdio to rmcp. Antigravity probes every stdio server with a custom `server/discover` request *before* `initialize`, and rmcp treats a non-`initialize` first message as fatal (`ExpectedInitializeRequest`) and exits β€” so the follow-up `initialize` hits a closed pipe. `src/mcp/prehandshake.rs` answers pre-handshake requests with JSON-RPC `-32601` and keeps the connection open; once `initialize` is forwarded it is a pass-through. Two background tasks pump real stdin/stdout through in-memory duplex pipes (`filtered_stdio()` in `src/mcp/server.rs`).
Commands are written once in canonical format (`/ns:command`) and auto-translated:
- Claude/Gemini: `/ns:command` (unchanged)
-- OpenCode/Cursor/Grok: `/ns-command` (colon β†’ hyphen, slash kept)
+- OpenCode/Cursor/Grok/Antigravity: `/ns-command` (colon β†’ hyphen, slash kept)
- Codex: `$ns-command` (slash β†’ dollar, colon β†’ hyphen)
- Copilot: no interactive skill invocation (prompt only, no commands sent)
@@ -191,7 +198,7 @@ Commands are written once in canonical format (`/ns:command`) and auto-translate
`send_skill_and_prompt()` has **three** send paths, because agent TUIs disagree about how a slash command plus arguments must arrive. Getting this wrong is the usual cause of "the agent started but never got the task":
1. **opencode** β€” its picker strips arguments if the whole string is typed at once. So: send the bare command name β†’ wait for the picker β†’ Enter (inserts it) β†’ send the args β†’ Enter
-2. **gemini / codex / cursor** β€” always combine skill + prompt into a *single* message via `send_keys_literal`, then poll the pane until the text renders before pressing Enter (Ink TUIs drop keys sent too early). Gemini executes-and-loses a separately sent prompt; Codex's `$skill` mentions are inline references that do nothing when sent standalone. Codex additionally needs a second Enter to dismiss its command picker
+2. **gemini / codex / cursor / antigravity** β€” always combine skill + prompt into a *single* message via `send_keys_literal`, then poll the pane until the text renders before pressing Enter (Ink TUIs drop keys sent too early). Gemini executes-and-loses a separately sent prompt; Codex's `$skill` mentions are inline references that do nothing when sent standalone. Codex additionally needs a second Enter to dismiss its command picker. Antigravity's slash-command picker closes as soon as arguments are typed, so the combined text submits on a single Enter (verified against agy 1.1.19) β€” no Codex-style second Enter
3. **everything else** (claude, copilot, grok) β€” the generic `match (skill_cmd, prompt_trigger)` path using `send_keys`, waiting on `prompt_triggers` between the command and the prompt when configured
`clear_context_on_advance` is applied before all three, and only for Claude (`/clear`, then poll until the pane stabilises).
@@ -492,7 +499,7 @@ Plugin defaults to the project's active plugin (set via `P` on the board).
### Agent Integration
- Agents spawned via `build_interactive_command()` in `src/agent/mod.rs`
-- Each agent has its own flags: Claude (`--dangerously-skip-permissions`), Codex (`--sandbox workspace-write`), Gemini (`GEMINI_TRUST_WORKSPACE=true` + `--approval-mode yolo`), Copilot (`--allow-all-tools`), Cursor (`agent --yolo`), Grok (`--yolo --trust`, where `--trust` also ungates the repo-local `.grok/config.toml` MCP server and suppresses the directory-trust dialog)
+- Each agent has its own flags: Claude (`--dangerously-skip-permissions`), Codex (`--sandbox workspace-write`), Gemini (`GEMINI_TRUST_WORKSPACE=true` + `--approval-mode yolo`), Copilot (`--allow-all-tools`), Cursor (`agent --yolo`), Grok (`--yolo --trust`, where `--trust` also ungates the repo-local `.grok/config.toml` MCP server and suppresses the directory-trust dialog), Antigravity (`agy --dangerously-skip-permissions --mode accept-edits` β€” two orthogonal controls: the flag governs shell/MCP/URL approvals, `--mode` governs the file-edit diff review, and both are needed to run unattended)
- `build_resume_command()` is the recovery variant used after a tmux/server restart β€” mostly `--continue`, but Gemini uses `--resume` and Codex uses `codex resume --last`
- Skills deployed to agent-native paths via `write_skills_to_worktree()` in app.rs
- Commands resolved per-task via `resolve_skill_command()` (plugin command + agent transform)
@@ -592,6 +599,7 @@ Detected automatically via `known_agents()` in order of preference:
5. **opencode** - AI-powered coding assistant
6. **cursor** - Cursor Agent CLI (binary is `agent`)
7. **grok** - xAI's Grok Build CLI
+8. **antigravity** - Google's Antigravity CLI (binary is `agy`)
## Future Enhancements
- Reopen Done tasks (recreate worktree from preserved branch)
diff --git a/README.md b/README.md
index dbb0611..e02018b 100644
--- a/README.md
+++ b/README.md
@@ -66,7 +66,7 @@ With the orchestrator, you don't even manage the board yourself. **An AI agent p
- **Parallel execution**: Every task gets its own git worktree and tmux window β€” run as many agents as needed, simultaneously
- **Spec-driven plugins**: Plug in [GSD](https://github.com/fynnfluegge/get-shit-done-cc), [Spec-kit](https://github.com/github/spec-kit), [OpenSpec](https://github.com/Fission-AI/OpenSpec), [BMAD](https://github.com/bmad-code-org/BMAD-METHOD), [Superpowers](https://github.com/obra/superpowers) β€” or define your own with a single TOML file
- **Multi-project dashboard**: Manage agent sessions across all projects via a single TUI
-- **Works with**: [Claude Code](https://github.com/anthropics/claude-code) | [Codex](https://github.com/openai/codex) | [Gemini CLI](https://github.com/google-gemini/gemini-cli) | [OpenCode](https://github.com/sst/opencode) | [Cursor Agent](https://cursor.com/docs/cli/overview) | [Copilot](https://github.com/github/copilot-cli) | [Grok Build](https://docs.x.ai/build/overview)
+- **Works with**: [Claude Code](https://github.com/anthropics/claude-code) | [Codex](https://github.com/openai/codex) | [Gemini CLI](https://github.com/google-gemini/gemini-cli) | [OpenCode](https://github.com/sst/opencode) | [Cursor Agent](https://cursor.com/docs/cli/overview) | [Copilot](https://github.com/github/copilot-cli) | [Grok Build](https://docs.x.ai/build/overview) | [Antigravity](https://github.com/google-antigravity/antigravity-cli)
> [!NOTE]
> Just need a plain coding agent session manager with **full human-in-the-loop control** and **no automatic spec-driven skill execution and orchestration** on advancing tasks?
@@ -261,6 +261,17 @@ mkdir -p ~/.grok/skills/agtx-sweep && cp skills/sweep/SKILL.md ~/.grok/skills/ag
</details>
+<details>
+<summary><strong>Antigravity</strong></summary>
+
+```bash
+agy mcp add agtx agtx mcp-serve
+mkdir -p ~/.gemini/antigravity-cli/skills/agtx-sweep
+cp skills/sweep/SKILL.md ~/.gemini/antigravity-cli/skills/agtx-sweep/SKILL.md
+```
+
+</details>
+
<details>
<summary><strong>Other</strong></summary>
@@ -362,21 +373,22 @@ Press `P` to switch plugins. Ships with 10 built-in:
Commands are written once in canonical format and automatically translated per agent:
-| Canonical (plugin.toml) | Claude / Gemini | Codex | OpenCode | Cursor | Grok |
-|--------------------------|-----------------|-------|----------|--------|------|
-| `/agtx:plan` | `/agtx:plan` | `$agtx-plan` | `/agtx-plan` | `/agtx-plan` | `/agtx-plan` |
-
-| | Claude | Codex | Gemini | OpenCode | Cursor | Copilot | Grok |
-|--|:------:|:-----:|:------:|:--------:|:------:|:-------:|:----:|
-| **agtx** | βœ… | βœ… | βœ… | βœ… | βœ… | 🟑 | βœ… |
-| **gsd** | βœ… | βœ… | βœ… | βœ… | βœ… | ❌ | βœ… |
-| **spec-kit** | βœ… | βœ… | βœ… | βœ… | βœ… | 🟑 | βœ… |
-| **openspec** | βœ… | βœ… | βœ… | βœ… | βœ… | 🟑 | βœ… |
-| **bmad** | βœ… | βœ… | βœ… | βœ… | βœ… | 🟑 | βœ… |
-| **superpowers** | βœ… | ❌ | ❌ | ❌ | ❌ | ❌ | ❌ |
-| **oh-my-claudecode** | βœ… | ❌ | ❌ | ❌ | ❌ | ❌ | ❌ |
-| **agent-skills** | βœ… | 🟑 | 🟑 | 🟑 | 🟑 | 🟑 | 🟑 |
-| **void** | βœ… | βœ… | βœ… | βœ… | βœ… | βœ… | βœ… |
+| Canonical (plugin.toml) | Claude / Gemini | Codex | OpenCode | Cursor | Grok | Antigravity |
+|--------------------------|-----------------|-------|----------|--------|------|-------------|
+| `/agtx:plan` | `/agtx:plan` | `$agtx-plan` | `/agtx-plan` | `/agtx-plan` | `/agtx-plan` | `/agtx-plan` |
+
+| | Claude | Codex | Gemini | OpenCode | Cursor | Copilot | Grok | Antigravity |
+|--|:------:|:-----:|:------:|:--------:|:------:|:-------:|:----:|:-----------:|
+| **agtx** | βœ… | βœ… | βœ… | βœ… | βœ… | 🟑 | βœ… | βœ… |
+| **gsd** | βœ… | βœ… | βœ… | βœ… | βœ… | ❌ | βœ… | ❌ |
+| **spec-kit** | βœ… | βœ… | βœ… | βœ… | βœ… | 🟑 | βœ… | βœ… |
+| **openspec** | βœ… | βœ… | βœ… | βœ… | βœ… | 🟑 | βœ… | βœ… |
+| **bmad** | βœ… | βœ… | βœ… | βœ… | βœ… | 🟑 | βœ… | βœ… |
+| **superpowers** | βœ… | ❌ | ❌ | ❌ | ❌ | ❌ | ❌ | ❌ |
+| **oh-my-claudecode** | βœ… | ❌ | ❌ | ❌ | ❌ | ❌ | ❌ | ❌ |
+| **agent-skills** | βœ… | 🟑 | 🟑 | 🟑 | 🟑 | 🟑 | 🟑 | 🟑 |
+| **void** | βœ… | βœ… | βœ… | βœ… | βœ… | βœ… | βœ… | βœ… |
+
βœ… Skills, commands, and prompts fully supported Β· 🟑 Prompt only, no interactive skill support Β· ❌ Not supported
@@ -448,7 +460,7 @@ review = ".my-plugin/{phase}/review.md"
# Claude/Gemini: /my-plugin:plan (unchanged)
# OpenCode: /my-plugin-plan (colon -> hyphen)
# Codex: $my-plugin-plan (slash -> dollar, colon -> hyphen)
-# Cursor/Grok: /my-plugin-plan (colon -> hyphen)
+# Cursor/Grok/Antigravity: /my-plugin-plan (colon -> hyphen)
# Omitted phases fall back to agent-native agtx skill invocation
# (e.g. /agtx:plan for Claude, $agtx-plan for Codex).
# Set to "" to skip sending a command for that phase.
diff --git a/src/agent/mod.rs b/src/agent/mod.rs
index 0d49939..2cc06a9 100644
--- a/src/agent/mod.rs
+++ b/src/agent/mod.rs
@@ -44,6 +44,9 @@ impl Agent {
"opencode" => "opencode --continue".to_string(),
"cursor" => "agent --yolo --continue".to_string(),
"grok" => "grok --yolo --trust --continue".to_string(),
+ "antigravity" => {
+ "agy --dangerously-skip-permissions --mode accept-edits --continue".to_string()
+ }
_ => self.build_interactive_command(""),
}
}
@@ -61,6 +64,9 @@ impl Agent {
"opencode" => "opencode".to_string(),
"cursor" => "agent --yolo".to_string(),
"grok" => "grok --yolo --trust".to_string(),
+ "antigravity" => {
+ "agy --dangerously-skip-permissions --mode accept-edits".to_string()
+ }
_ => self.command.clone(),
};
}
@@ -74,6 +80,12 @@ impl Agent {
"opencode" => format!("opencode -p '{}'", escaped_prompt),
"cursor" => format!("agent --yolo '{}'", escaped_prompt),
"grok" => format!("grok --yolo --trust '{}'", escaped_prompt),
+ // -i / --prompt-interactive runs the prompt and keeps the session open,
+ // the same shape as Gemini's -i.
+ "antigravity" => format!(
+ "agy --dangerously-skip-permissions --mode accept-edits -i '{}'",
+ escaped_prompt
+ ),
_ => format!("{} '{}'", self.command, escaped_prompt),
}
}
@@ -124,6 +136,12 @@ pub fn known_agents() -> Vec<Agent> {
"xAI's Grok Build CLI",
),
+ Agent::new(
+ "antigravity",
+ "agy",
+ "Google's Antigravity CLI",
+ "Antigravity <[email protected]>",
+ ),
// TODO: investigate CLI usage before enabling
// Agent::new("aider", "aider", "AI pair programming in your terminal", "Aider <[email protected]>"),
// Agent::new("cline", "cline", "AI coding assistant for VS Code", "Cline <[email protected]>"),
diff --git a/src/agent/operations.rs b/src/agent/operations.rs
index d843e30..36fdde7 100644
--- a/src/agent/operations.rs
+++ b/src/agent/operations.rs
@@ -62,6 +62,7 @@ impl AgentOperations for CodingAgent {
"gemini" => ("gemini", vec!["-p", prompt]),
"cursor" => ("agent", vec!["--print", "--yolo", prompt]),
"grok" => ("grok", vec!["-p", prompt]),
+ "antigravity" => ("agy", vec!["-p", prompt]),
_ => (self.agent.command.as_str(), vec![prompt]),
};
diff --git a/src/mcp/mod.rs b/src/mcp/mod.rs
index 12ce948..90df880 100644
--- a/src/mcp/mod.rs
+++ b/src/mcp/mod.rs
@@ -1,3 +1,4 @@
+mod prehandshake;
mod server;
pub use server::serve;
diff --git a/src/mcp/prehandshake.rs b/src/mcp/prehandshake.rs
new file mode 100644
index 0000000..ca491f1
--- /dev/null
+++ b/src/mcp/prehandshake.rs
@@ -0,0 +1,206 @@
+//! Pre-handshake stdin filter for the MCP server.
+//!
+//! rmcp refuses to start if the first client message is anything other than
+//! `initialize` β€” it returns `ExpectedInitializeRequest` and the process exits.
+//! Antigravity CLI (`agy`) probes every stdio server with a custom
+//! `server/discover` request *before* `initialize`, so an unfiltered rmcp server
+//! dies during discovery and `agy`'s follow-up `initialize` hits a closed pipe
+//! ("connection closed: calling \"initialize\": client is closing: EOF").
+//!
+//! JSON-RPC already has the right answer for an unknown method: reply with
+//! -32601 and keep the connection open. This module does exactly that for
+//! requests arriving before `initialize`, and forwards everything else
+//! untouched. Once `initialize` has been forwarded, the filter is a pass-through
+//! β€” rmcp handles unknown methods itself from then on.
+
+use serde_json::Value;
+
+/// JSON-RPC "method not found".
+const METHOD_NOT_FOUND: i32 = -32601;
+
+/// What to do with a client message that arrived before `initialize`.
+#[derive(Debug, PartialEq, Eq)]
+pub enum PreInitAction {
+ /// Pass the line through to rmcp untouched.
+ Forward,
+ /// Answer with a -32601 error and do not forward. Carries the serialized
+ /// response line.
+ Reject(String),
+ /// Drop silently β€” a notification we cannot answer and rmcp would reject.
+ Drop,
+}
+
+/// Classify a single client line seen before the handshake completes.
+///
+/// Anything we cannot parse is forwarded: rmcp's own error handling is a better
+/// place to deal with malformed input than a guess here.
+pub fn classify_pre_init(line: &str) -> PreInitAction {
+ let value: Value = match serde_json::from_str(line) {
+ Ok(v) => v,
+ Err(_) => return PreInitAction::Forward,
+ };
+
+ let method = match value.get("method").and_then(Value::as_str) {
+ Some(m) => m,
+ // A response or malformed object β€” not ours to interpret.
+ None => return PreInitAction::Forward,
+ };
+
+ if method == "initialize" {
+ return PreInitAction::Forward;
+ }
+
+ match value.get("id") {
+ // A request: answer it so the client can move on to `initialize`.
+ Some(id) if !id.is_null() => {
+ let response = serde_json::json!({
+ "jsonrpc": "2.0",
+ "id": id,
+ "error": {
+ "code": METHOD_NOT_FOUND,
+ "message": format!("Method not found: {method}"),
+ },
+ });
+ PreInitAction::Reject(response.to_string())
+ }
+ // A notification: nothing to answer, and forwarding it would abort the
+ // handshake.
+ _ => PreInitAction::Drop,
+ }
+}
+
+/// Tracks whether `initialize` has been forwarded yet.
+#[derive(Debug, Default)]
+pub struct HandshakeFilter {
+ initialized: bool,
+}
+
+impl HandshakeFilter {
+ pub fn new() -> Self {
+ Self::default()
+ }
+
+ /// Classify the next client line. After `initialize` has gone through, every
+ /// line is forwarded β€” rmcp answers unknown methods correctly once running.
+ pub fn next(&mut self, line: &str) -> PreInitAction {
+ if self.initialized {
+ return PreInitAction::Forward;
+ }
+ let action = classify_pre_init(line);
+ if action == PreInitAction::Forward && line.contains("\"initialize\"") {
+ // Only flip once the message we forwarded really was the handshake;
+ // `classify_pre_init` forwards unparseable lines too.
+ if let Ok(v) = serde_json::from_str::<Value>(line) {
+ if v.get("method").and_then(Value::as_str) == Some("initialize") {
+ self.initialized = true;
+ }
+ }
+ }
+ action
+ }
+}
+
+#[cfg(test)]
+mod tests {
+ use super::*;
+
+ fn init_line() -> String {
+ serde_json::json!({
+ "jsonrpc": "2.0",
+ "id": 1,
+ "method": "initialize",
+ "params": {"protocolVersion": "2024-11-05", "capabilities": {}}
+ })
+ .to_string()
+ }
+
+ #[test]
+ fn initialize_is_forwarded() {
+ assert_eq!(classify_pre_init(&init_line()), PreInitAction::Forward);
+ }
+
+ #[test]
+ fn agy_server_discover_is_rejected_not_forwarded() {
+ // The exact probe Antigravity CLI 1.1.19 sends before `initialize`.
+ let line = r#"{"jsonrpc":"2.0","id":1,"method":"server/discover","params":{}}"#;
+ match classify_pre_init(line) {
+ PreInitAction::Reject(response) => {
+ let v: Value = serde_json::from_str(&response).unwrap();
+ assert_eq!(v["id"], 1);
+ assert_eq!(v["error"]["code"], METHOD_NOT_FOUND);
+ assert!(
+ v["error"]["message"]
+ .as_str()
+ .unwrap()
+ .contains("server/discover"),
+ "message should name the method: {response}"
+ );
+ // A rejection must never look like a success to the client.
+ assert!(v.get("result").is_none());
+ }
+ other => panic!("expected Reject, got {other:?}"),
+ }
+ }
+
+ #[test]
+ fn pre_init_notification_is_dropped() {
+ let line = r#"{"jsonrpc":"2.0","method":"notifications/cancelled"}"#;
+ assert_eq!(classify_pre_init(line), PreInitAction::Drop);
+ }
+
+ #[test]
+ fn null_id_counts_as_notification() {
+ let line = r#"{"jsonrpc":"2.0","id":null,"method":"server/discover"}"#;
+ assert_eq!(classify_pre_init(line), PreInitAction::Drop);
+ }
+
+ #[test]
+ fn malformed_input_is_left_to_rmcp() {
+ assert_eq!(classify_pre_init("not json"), PreInitAction::Forward);
+ assert_eq!(classify_pre_init(""), PreInitAction::Forward);
+ }
+
+ #[test]
+ fn string_ids_are_echoed_verbatim() {
+ let line = r#"{"jsonrpc":"2.0","id":"abc-1","method":"server/discover"}"#;
+ match classify_pre_init(line) {
+ PreInitAction::Reject(response) => {
+ let v: Value = serde_json::from_str(&response).unwrap();
+ assert_eq!(v["id"], "abc-1");
+ }
+ other => panic!("expected Reject, got {other:?}"),
+ }
+ }
+
+ #[test]
+ fn filter_passes_everything_through_after_initialize() {
+ let mut filter = HandshakeFilter::new();
+ // The agy probe first...
+ assert!(matches!(
+ filter.next(r#"{"jsonrpc":"2.0","id":1,"method":"server/discover"}"#),
+ PreInitAction::Reject(_)
+ ));
+ // ...then the real handshake...
+ assert_eq!(filter.next(&init_line()), PreInitAction::Forward);
+ // ...after which rmcp owns error handling, including for the same probe.
+ assert_eq!(
+ filter.next(r#"{"jsonrpc":"2.0","id":2,"method":"server/discover"}"#),
+ PreInitAction::Forward
+ );
+ assert_eq!(
+ filter.next(r#"{"jsonrpc":"2.0","id":3,"method":"tools/list"}"#),
+ PreInitAction::Forward
+ );
+ }
+
+ #[test]
+ fn unparseable_line_does_not_flip_the_initialized_flag() {
+ let mut filter = HandshakeFilter::new();
+ // Contains the word but is not a handshake β€” must not open the gate.
+ assert_eq!(filter.next(r#"garbage "initialize" garbage"#), PreInitAction::Forward);
+ assert!(matches!(
+ filter.next(r#"{"jsonrpc":"2.0","id":9,"method":"server/discover"}"#),
+ PreInitAction::Reject(_)
+ ));
+ }
+}
diff --git a/src/mcp/server.rs b/src/mcp/server.rs
index bb1e882..fbf47a7 100644
--- a/src/mcp/server.rs
+++ b/src/mcp/server.rs
@@ -5,7 +5,6 @@ use rmcp::{
handler::server::{router::tool::ToolRouter, wrapper::Parameters},
model::{ServerCapabilities, ServerInfo},
schemars, tool, tool_handler, tool_router,
- transport::io::stdio,
ServerHandler, ServiceExt,
};
use serde::{Deserialize, Serialize};
@@ -1281,7 +1280,85 @@ pub async fn serve(project_path: Option<PathBuf>) -> anyhow::Result<()> {
};
let server = AgtxMcpServer::new(mode);
- let service = server.serve(stdio()).await?;
+ let service = server.serve(filtered_stdio()).await?;
service.waiting().await?;
Ok(())
}
+
+/// Buffer size for the in-memory pipes bridging real stdio to rmcp.
+const PIPE_BUF: usize = 64 * 1024;
+
+/// stdio for rmcp, with pre-handshake requests answered instead of fatal.
+///
+/// rmcp aborts if the first message is not `initialize`, which Antigravity CLI
+/// triggers by probing with `server/discover` first. See `prehandshake` for the
+/// full story. Returns a (reader, writer) pair rmcp can serve on; two background
+/// tasks pump real stdin/stdout through it.
+fn filtered_stdio() -> (tokio::io::DuplexStream, tokio::io::DuplexStream) {
+ use crate::mcp::prehandshake::{HandshakeFilter, PreInitAction};
+ use std::sync::Arc;
+ use tokio::io::{AsyncBufReadExt, AsyncWriteExt, BufReader};
+ use tokio::sync::Mutex;
+
+ // client β†’ us β†’ rmcp
+ let (mut to_rmcp, rmcp_reader) = tokio::io::duplex(PIPE_BUF);
+ // rmcp β†’ us β†’ client
+ let (rmcp_writer, mut from_rmcp) = tokio::io::duplex(PIPE_BUF);
+
+ // Both the filter (error replies) and rmcp (real responses) write to stdout.
+ let stdout = Arc::new(Mutex::new(tokio::io::stdout()));
+
+ // Pump 1: real stdin β†’ filter β†’ rmcp.
+ let filter_stdout = stdout.clone();
+ tokio::spawn(async move {
+ let mut lines = BufReader::new(tokio::io::stdin()).lines();
+ let mut filter = HandshakeFilter::new();
+ while let Ok(Some(line)) = lines.next_line().await {
+ match filter.next(&line) {
+ PreInitAction::Forward => {
+ if to_rmcp.write_all(line.as_bytes()).await.is_err()
+ || to_rmcp.write_all(b"\n").await.is_err()
+ || to_rmcp.flush().await.is_err()
+ {
+ break;
+ }
+ }
+ PreInitAction::Reject(response) => {
+ let mut out = filter_stdout.lock().await;
+ if out.write_all(response.as_bytes()).await.is_err()
+ || out.write_all(b"\n").await.is_err()
+ || out.flush().await.is_err()
+ {
+ break;
+ }
+ tracing::debug!(
+ "answered pre-handshake request with method-not-found: {}",
+ line
+ );
+ }
+ PreInitAction::Drop => {
+ tracing::debug!("dropped pre-handshake notification: {}", line);
+ }
+ }
+ }
+ // EOF on stdin β€” closing our end shuts rmcp down cleanly.
+ drop(to_rmcp);
+ });
+
+ // Pump 2: rmcp β†’ real stdout.
+ tokio::spawn(async move {
+ let mut buf = vec![0u8; 8192];
+ loop {
+ let n = match tokio::io::AsyncReadExt::read(&mut from_rmcp, &mut buf).await {
+ Ok(0) | Err(_) => break,
+ Ok(n) => n,
+ };
+ let mut out = stdout.lock().await;
+ if out.write_all(&buf[..n]).await.is_err() || out.flush().await.is_err() {
+ break;
+ }
+ }
+ });
+
+ (rmcp_reader, rmcp_writer)
+}
diff --git a/src/skills.rs b/src/skills.rs
index be8de2d..3153da0 100644
--- a/src/skills.rs
+++ b/src/skills.rs
@@ -112,6 +112,9 @@ pub fn agent_native_skill_dir(agent_name: &str) -> Option<(&'static str, &'stati
"codex" => Some((".codex/skills", "")),
"cursor" => Some((".cursor/skills", "")),
"grok" => Some((".grok/skills", "")),
+ // Antigravity reads workspace skills from the vendor-neutral `.agents/` tree,
+ // not from an agent-specific dotdir.
+ "antigravity" => Some((".agents/skills", "")),
"copilot" => Some((".github/agents", "agtx")),
_ => None,
}
@@ -162,7 +165,7 @@ pub fn skill_dir_to_filename(skill_dir_name: &str, agent_name: &str) -> String {
/// - Claude/Gemini: unchanged (`/gsd:plan-phase 1`)
/// - OpenCode: colon β†’ hyphen (`/gsd-plan-phase 1`)
/// - Codex: slash β†’ dollar + colon β†’ hyphen (`$gsd-plan-phase 1`)
-/// - Cursor/Grok: colon β†’ hyphen, slash kept (`/gsd-plan-phase 1`)
+/// - Cursor/Grok/Antigravity: colon β†’ hyphen, slash kept (`/gsd-plan-phase 1`)
/// - Unsupported agents: None (will fall back to file-path reference)
pub fn transform_plugin_command(canonical_cmd: &str, agent_name: &str) -> Option<String> {
match agent_name {
@@ -180,7 +183,7 @@ pub fn transform_plugin_command(canonical_cmd: &str, agent_name: &str) -> Option
Some(transformed)
}
}
- "cursor" | "grok" => {
+ "cursor" | "grok" | "antigravity" => {
// /agtx:plan β†’ /agtx-plan (slash kept, colon β†’ hyphen)
Some(canonical_cmd.replacen(':', "-", 1))
}
@@ -432,7 +435,7 @@ pub fn scan_agent_skills(
}
}
}
- "cursor" | "grok" => {
+ "cursor" | "grok" | "antigravity" => {
// Skill subdirectories with SKILL.md, invoked as /skill-name
let base_dir = match agent_native_skill_dir(agent_name) {
Some((dir, _)) => dir,
diff --git a/src/tui/app.rs b/src/tui/app.rs
index 0ae2dce..89cf626 100644
--- a/src/tui/app.rs
+++ b/src/tui/app.rs
@@ -2686,6 +2686,7 @@ impl App {
"opencode" => Style::default().fg(Color::White).bg(Color::Rgb(80, 80, 80)), // white on grey
"codex" => Style::default().fg(Color::White).bg(Color::Rgb(20, 20, 20)), // white on black
"grok" => Style::default().fg(Color::Rgb(20, 20, 20)).bg(Color::White), // black on white
+ "antigravity" => Style::default().fg(Color::Rgb(120, 190, 255)), // light blue
_ => Style::default().fg(Color::White),
};
let agent_label = Paragraph::new(format!(" {} ", task.agent))
@@ -8715,12 +8716,16 @@ fn send_skill_and_prompt(
return;
}
- // Gemini, Codex & cursor: always combine skill+prompt into a single message.
+ // Gemini, Codex, cursor & antigravity: always combine skill+prompt into a
+ // single message.
// Gemini: sending separately causes it to execute the skill and queue the
// prompt, which gets lost or arrives too late.
// Codex: skill mentions ($skill-name) are inline references that must be
// part of a message β€” sending just "$skill" standalone does nothing.
- if matches!(agent_name, "gemini" | "codex" | "cursor") {
+ // Antigravity: descends from the Gemini CLI lineage (settings live under
+ // ~/.gemini/), so it is treated as Ink-class and gets the same
+ // wait-for-echo send. Not yet confirmed against a live session.
+ if matches!(agent_name, "gemini" | "codex" | "cursor" | "antigravity") {
let text_to_send = if let Some(cmd) = skill_cmd {
if !prompt.is_empty() {
Some(format!("{}\n\n{}", cmd, prompt))
@@ -9113,7 +9118,8 @@ fn collect_phase_agents(config: &MergedConfig) -> Vec<String> {
/// Note: on systems where agents are installed via asdf/nvm, all agents run as `node`
/// and Check 1 never fires β€” AGENT_ACTIVE_INDICATORS is the only reliable signal there.
const AGENT_COMMANDS: &[&str] = &[
- "claude", "codex", "gemini", "copilot", "opencode", "agent", "grok", "python3", "python",
+ "claude", "codex", "gemini", "copilot", "opencode", "agent", "grok", "agy", "python3",
+ "python",
];
/// Strings in pane content that indicate an agent TUI is active and ready.
@@ -9564,6 +9570,21 @@ fn load_plugin_if_configured(
.or_else(|| skills::load_bundled_plugin("agtx"))
}
+/// Home directory for agent-global config that agtx writes as a trust
+/// side-effect β€” today only Codex's `~/.codex/config.toml`.
+///
+/// `AGTX_AGENT_HOME` overrides `$HOME` so tests can exercise that write without
+/// appending temp-dir trust entries to the real user's config, which is
+/// otherwise exactly what running the suite does.
+fn agent_trust_home() -> Option<PathBuf> {
+ if let Ok(dir) = std::env::var("AGTX_AGENT_HOME") {
+ if !dir.is_empty() {
+ return Some(PathBuf::from(dir));
+ }
+ }
+ std::env::var("HOME").ok().map(PathBuf::from)
+}
+
/// Write skill files to a worktree's .agtx/skills/ directory and agent-native discovery paths.
/// `agent_names` determines which native paths to use (e.g. `.claude/commands/agtx/` for Claude).
/// When multiple agents are configured for different phases, skills are deployed for all of them.
@@ -9649,8 +9670,8 @@ fn write_skills_to_worktree(
// Codex only loads project-local .codex/config.toml for trusted paths.
// Add a trust entry for this worktree to ~/.codex/config.toml.
- if let Ok(home) = std::env::var("HOME") {
- let global_config_path = Path::new(&home).join(".codex").join("config.toml");
+ if let Some(home) = agent_trust_home() {
+ let global_config_path = home.join(".codex").join("config.toml");
let trust_entry = format!(
"\n[projects.\"{}\"]\ntrust_level = \"trusted\"\n",
worktree_path
@@ -9718,6 +9739,32 @@ fn write_skills_to_worktree(
let _ = std::fs::write(&path, merged);
}
}
+ "antigravity" => {
+ // Antigravity reads workspace MCP servers from .agents/mcp_config.json
+ // (JSON, `mcpServers`). `.agents/` is vendor-neutral and may already be
+ // tracked in the repo, so merge the agtx entry into any existing file
+ // instead of clobbering the project's own servers.
+ let dir = Path::new(worktree_path).join(".agents");
+ let _ = std::fs::create_dir_all(&dir);
+ let path = dir.join("mcp_config.json");
+ let mut root = std::fs::read_to_string(&path)
+ .ok()
+ .and_then(|s| serde_json::from_str::<serde_json::Value>(&s).ok())
+ .filter(|v| v.is_object())
+ .unwrap_or_else(|| serde_json::json!({}));
+ if !root["mcpServers"].is_object() {
+ root["mcpServers"] = serde_json::json!({});
+ }
+ root["mcpServers"]["agtx"] = serde_json::json!({
+ "command": &agtx_bin,
+ "args": ["mcp-serve", &project_path_str]
+ });
+ let _ = std::fs::write(
+ &path,
+ serde_json::to_string_pretty(&root).unwrap_or_default(),
+ );
+
+ }
"opencode" => {
let cfg = serde_json::json!({
"mcp": {
@@ -9760,8 +9807,8 @@ fn write_skills_to_worktree(
let filename = skills::skill_dir_to_filename(skill_dir_name, agent_name);
let _ = std::fs::write(native_dir.join(&filename), toml_content);
}
- "codex" | "cursor" | "grok" => {
- // Codex/Cursor/Grok use SKILL.md in skill-name/ subdirectories
+ "codex" | "cursor" | "grok" | "antigravity" => {
+ // Codex/Cursor/Grok/Antigravity use SKILL.md in skill-name/ subdirectories
let skill_subdir = native_dir.join(skill_dir_name);
let _ = std::fs::create_dir_all(&skill_subdir);
let _ = std::fs::write(skill_subdir.join("SKILL.md"), &content);
@@ -9815,7 +9862,7 @@ fn deploy_skill(target_dir: &Path, skill_name: &str, content: &str, agent_name:
let filename = skills::skill_dir_to_filename(skill_name, agent_name);
let _ = std::fs::write(native_dir.join(&filename), toml_content);
}
- "codex" | "cursor" | "grok" => {
+ "codex" | "cursor" | "grok" | "antigravity" => {
let skill_subdir = native_dir.join(skill_name);
let _ = std::fs::create_dir_all(&skill_subdir);
let _ = std::fs::write(skill_subdir.join("SKILL.md"), content);
diff --git a/src/tui/app_tests.rs b/src/tui/app_tests.rs
index 765febb..9e42e9c 100644
--- a/src/tui/app_tests.rs
+++ b/src/tui/app_tests.rs
@@ -3827,6 +3827,8 @@ fn test_write_skills_to_worktree_gemini_toml() {
#[test]
fn test_write_skills_to_worktree_codex() {
+ // The codex arm appends a trust entry to ~/.codex/config.toml β€” redirect it.
+ let (_home, _guard) = redirect_agent_home();
let dir = tempfile::tempdir().unwrap();
let wt = dir.path().to_string_lossy().to_string();
@@ -3950,8 +3952,111 @@ fn test_write_skills_to_worktree_grok_skills() {
assert!(dir.path().join(".agtx/skills/agtx-plan/SKILL.md").exists());
}
+/// Redirect agent-global trust writes into a per-process temp HOME, and
+/// serialize the tests that do so.
+///
+/// Without the redirect, every run of the suite appends a temp-dir trust entry
+/// to the real user's `~/.codex/config.toml` and
+/// `~/.gemini/antigravity-cli/settings.json`. The lock is needed because the
+/// redirect target is process-global: these writes are read-modify-write on one
+/// shared file, so concurrent tests would clobber each other's entries.
+///
+/// Hold the returned guard for the duration of the test.
+fn redirect_agent_home() -> (std::path::PathBuf, std::sync::MutexGuard<'static, ()>) {
+ static AGENT_HOME: std::sync::OnceLock<tempfile::TempDir> = std::sync::OnceLock::new();
+ static LOCK: std::sync::Mutex<()> = std::sync::Mutex::new(());
+ // A panicking test poisons the lock; the data is unit, so recover and carry on.
+ let guard = LOCK.lock().unwrap_or_else(|e| e.into_inner());
+ let dir = AGENT_HOME.get_or_init(|| tempfile::tempdir().unwrap());
+ std::env::set_var("AGTX_AGENT_HOME", dir.path());
+ (dir.path().to_path_buf(), guard)
+}
+
+#[test]
+fn test_write_skills_to_worktree_mcp_antigravity() {
+ let dir = tempfile::tempdir().unwrap();
+ let wt = dir.path().to_string_lossy().to_string();
+
+ write_skills_to_worktree(&wt, dir.path(), &None, &["antigravity"]);
+
+ let cfg = dir.path().join(".agents/mcp_config.json");
+ assert!(
+ cfg.exists(),
+ ".agents/mcp_config.json should be written for antigravity"
+ );
+ let content = std::fs::read_to_string(&cfg).unwrap();
+ let v: serde_json::Value = serde_json::from_str(&content).unwrap();
+ assert!(v["mcpServers"]["agtx"]["command"].is_string());
+ assert_eq!(v["mcpServers"]["agtx"]["args"][0], "mcp-serve");
+}
+
+#[test]
+fn test_write_skills_to_worktree_mcp_antigravity_preserves_existing_config() {
+ let dir = tempfile::tempdir().unwrap();
+ let wt = dir.path().to_string_lossy().to_string();
+ let agents_dir = dir.path().join(".agents");
+ std::fs::create_dir_all(&agents_dir).unwrap();
+ std::fs::write(
+ agents_dir.join("mcp_config.json"),
+ r#"{"mcpServers":{"other":{"command":"other"}},"somethingElse":true}"#,
+ )
+ .unwrap();
+
+ write_skills_to_worktree(&wt, dir.path(), &None, &["antigravity"]);
+
+ let content = std::fs::read_to_string(agents_dir.join("mcp_config.json")).unwrap();
+ let v: serde_json::Value = serde_json::from_str(&content).unwrap();
+ assert_eq!(
+ v["mcpServers"]["other"]["command"], "other",
+ "a project's own .agents/mcp_config.json must not be clobbered: {content}"
+ );
+ assert_eq!(
+ v["somethingElse"], true,
+ "top-level sibling keys must survive: {content}"
+ );
+ assert!(v["mcpServers"]["agtx"]["command"].is_string());
+}
+
+#[test]
+fn test_write_skills_to_worktree_mcp_antigravity_replaces_malformed_config() {
+ let dir = tempfile::tempdir().unwrap();
+ let wt = dir.path().to_string_lossy().to_string();
+ let agents_dir = dir.path().join(".agents");
+ std::fs::create_dir_all(&agents_dir).unwrap();
+ std::fs::write(agents_dir.join("mcp_config.json"), "not json at all").unwrap();
+
+ write_skills_to_worktree(&wt, dir.path(), &None, &["antigravity"]);
+
+ let content = std::fs::read_to_string(agents_dir.join("mcp_config.json")).unwrap();
+ let v: serde_json::Value =
+ serde_json::from_str(&content).expect("a malformed file must be replaced with valid JSON");
+ assert!(v["mcpServers"]["agtx"]["command"].is_string());
+}
+
+#[test]
+fn test_write_skills_to_worktree_antigravity_skills() {
+ let dir = tempfile::tempdir().unwrap();
+ let wt = dir.path().to_string_lossy().to_string();
+
+ write_skills_to_worktree(&wt, dir.path(), &None, &["antigravity"]);
+
+ let skill = dir.path().join(".agents/skills/agtx-plan/SKILL.md");
+ assert!(
+ skill.exists(),
+ "antigravity skills go to .agents/skills/<name>/SKILL.md"
+ );
+ let content = std::fs::read_to_string(&skill).unwrap();
+ assert!(
+ content.starts_with("---"),
+ "frontmatter must be kept for antigravity"
+ );
+ // Canonical copy is always written too
+ assert!(dir.path().join(".agtx/skills/agtx-plan/SKILL.md").exists());
+}
+
#[test]
fn test_write_skills_to_worktree_mcp_codex() {
+ let (_home, _guard) = redirect_agent_home();
let dir = tempfile::tempdir().unwrap();
let wt = dir.path().to_string_lossy().to_string();
diff --git a/tests/agent_tests.rs b/tests/agent_tests.rs
index cf3867b..8ed5f6e 100644
--- a/tests/agent_tests.rs
+++ b/tests/agent_tests.rs
@@ -60,7 +60,16 @@ fn test_known_agents_includes_cursor() {
fn test_known_agents_includes_all_expected() {
let agents = known_agents();
let names: Vec<&str> = agents.iter().map(|a| a.name.as_str()).collect();
- for expected in &["claude", "codex", "copilot", "gemini", "opencode", "cursor", "grok"] {
+ for expected in &[
+ "claude",
+ "codex",
+ "copilot",
+ "gemini",
+ "opencode",
+ "cursor",
+ "grok",
+ "antigravity",
+ ] {
assert!(names.contains(expected), "missing agent: {}", expected);
}
}
@@ -150,6 +159,10 @@ fn test_build_resume_command_all_agents() {
by_name("grok").build_resume_command(),
"grok --yolo --trust --continue"
);
+ assert_eq!(
+ by_name("antigravity").build_resume_command(),
+ "agy --dangerously-skip-permissions --mode accept-edits --continue"
+ );
}
#[test]
@@ -298,3 +311,72 @@ fn test_grok_transform_plugin_command() {
Some("/gsd-plan-phase 1".to_string())
);
}
+
+// =============================================================================
+// Tests for antigravity (Google Antigravity CLI) integration
+// =============================================================================
+
+#[test]
+fn test_known_agents_includes_antigravity() {
+ let agents = known_agents();
+ let agy = agents.iter().find(|a| a.name == "antigravity");
+ assert!(agy.is_some(), "antigravity should be in known_agents");
+ let agy = agy.unwrap();
+ // Agent name and binary differ, like Cursor (`cursor` / `agent`).
+ assert_eq!(agy.command, "agy");
+ assert_eq!(agy.co_author, "Antigravity <[email protected]>");
+}
+
+#[test]
+fn test_build_interactive_command_antigravity_no_prompt() {
+ let agents = known_agents();
+ let agy = agents.iter().find(|a| a.name == "antigravity").unwrap();
+ // Both permission controls are needed: --mode governs the file-edit diff
+ // review, --dangerously-skip-permissions governs shell/MCP/URL approvals.
+ assert_eq!(
+ agy.build_interactive_command(""),
+ "agy --dangerously-skip-permissions --mode accept-edits"
+ );
+}
+
+#[test]
+fn test_build_interactive_command_antigravity_with_prompt() {
+ let agents = known_agents();
+ let agy = agents.iter().find(|a| a.name == "antigravity").unwrap();
+ assert_eq!(
+ agy.build_interactive_command("do something"),
+ "agy --dangerously-skip-permissions --mode accept-edits -i 'do something'"
+ );
+}
+
+#[test]
+fn test_build_interactive_command_antigravity_escapes_single_quotes() {
+ let agents = known_agents();
+ let agy = agents.iter().find(|a| a.name == "antigravity").unwrap();
+ let cmd = agy.build_interactive_command("it's a test");
+ assert!(
+ cmd.starts_with("agy --dangerously-skip-permissions --mode accept-edits -i "),
+ "should use the agy flags: {cmd}"
+ );
+ assert!(cmd.contains("'\"'\"'"), "single quote must be escaped: {cmd}");
+}
+
+#[test]
+fn test_antigravity_has_native_skill_dir() {
+ // Antigravity uses the vendor-neutral `.agents/` tree, not an agent dotdir.
+ let dir = agent_native_skill_dir("antigravity");
+ assert_eq!(dir, Some((".agents/skills", "")));
+}
+
+#[test]
+fn test_antigravity_transform_plugin_command() {
+ // Antigravity: colon β†’ hyphen, slash kept (same as Cursor/Grok)
+ assert_eq!(
+ transform_plugin_command("/agtx:plan", "antigravity"),
+ Some("/agtx-plan".to_string())
+ );
+ assert_eq!(
+ transform_plugin_command("/gsd:plan-phase 1", "antigravity"),
+ Some("/gsd-plan-phase 1".to_string())
+ );
+}