Skip to main content
Glama
Antigravity Win Explorer

Antigravity Win Explorer

by tino0190
README.md
<div align="center">
  <img src="./assets/logo.svg" alt="Antigravity Win Explorer Logo" width="88" height="88" />
  <h1>Antigravity Win Explorer (<code>antigravity-win-explorer</code>)</h1>
  <p>
    <strong>面向 Windows 优先打造的 Google Antigravity 2.0 文件资源管理器 &amp; 产物定位 MCP App 插件</strong>
  </p>
  <p>
    <a href="./README.md"><strong>简体中文</strong></a> · <a href="./README.en.md">English</a>
  </p>
  <p>
    <img src="https://img.shields.io/badge/Platform-Windows%20%7C%20macOS%20%7C%20Linux-2563EB?style=flat-square" alt="Platform" />
    <img src="https://img.shields.io/badge/Protocol-MCP%20Apps%20(SEP--1865)-16A34A?style=flat-square" alt="MCP Apps" />
    <img src="https://img.shields.io/badge/Runtime-Zero%20Deps%20Node.js%2018+-F59E0B?style=flat-square" alt="Node.js 18+" />
    <img src="https://img.shields.io/badge/License-MIT-6B7280?style=flat-square" alt="MIT License" />
  </p>
</div>

---

## 为什么需要这个插件?

在 **Windows** 上使用 Google Antigravity 2.0 桌面端时,常见的几个高频痛点:

1. **聊天气泡里的文件链接无法一键在资源管理器中定位**:点击文件胶囊通常只能复制或在应用内预览,无法像日常开发那样直接弹出 Windows 资源管理器并高亮选中该文件(`explorer.exe /select,`)。
2. **外部文件不方便直接用默认软件打开**:AI 生成的 `.pdf`、`.docx`、`.xlsx`、`.png` 等交付物,每次都要手动复制路径去文件夹找,再用 Word / Excel / PDF 阅读器打开。
3. **右侧工作区缺少完整右键菜单 & 隐藏产物难找**:Antigravity 对话产物默认保存在隐藏目录 `%USERPROFILE%\.gemini\antigravity\brain\` 下,平时排查历史输出非常麻烦。
4. **现有社区同类插件大多只适配 macOS**:依赖 `bash` 启动脚本和 macOS 专用的 `open -R`,在 Windows 上直接不可用。

**`antigravity-win-explorer`** 将**聊天内嵌交互卡片**与**侧边栏全功能文件浏览器**合二为一,原生采用 `node` 启动(**无需 Bash、无需 `npm install`**),专为 Windows 10/11 打磨,同时也完整兼容 macOS(访达)和 Linux(`xdg-open`)。

---

## 核心功能一览

| 入口 / 视图 | 核心能力 | 交互体验 |
| :--- | :--- | :--- |
| **1. 聊天内嵌文件卡片**<br>*(MCP App + 自动规则)* | AI 每次产出文档、脚本、报告或图片时,自动在回复末尾渲染紧凑的交互文件卡片 | • **双击文件行** 或点击 **`在资源管理器中显示`** → 调用 `explorer.exe /select,` 精准高亮选中文件<br>• 点击 **`打开`** → 调用 Windows 默认程序直接打开(Word / PDF / 看图等)<br>• 点击 **`预览`**(或单击文件名)→ 在 Antigravity 右侧标签页中直接预览<br>• 点击 **`📋`** → 一键复制完整路径 |
| **2. 侧边栏 / 全局文件浏览器**<br>*(Side Pane + Global 入口)* | 在右侧辅助栏 `+` 菜单及左侧栏提供 **`Win 资源管理器`** 面板 | • **完整右键菜单**:在资源管理器中显示、用默认程序打开、在标签页中预览、**在 Windows Terminal / PowerShell 中打开**、复制完整路径、收藏目录<br>• **盘符与快捷目录条**:一键切换 `C:` / `D:` 等本机所有盘符,以及桌面、下载、文档、Brain 产物、Scratch 目录<br>• **`Ctrl + L` 路径直达**、实时文件名筛选、隐藏文件(`.*`)开关、`00_` 前缀置顶 |
| **3. 最近产出扫描**<br>*(Recent Outputs)* | 一键扫描隐藏目录 `~/.gemini/antigravity/brain` 与 `scratch` | • 按最新修改时间排序,支持按来源(Brain / Scratch)与关键词过滤<br>• 找回任意历史对话产物并一键定位、打开或预览 |
| **4. 收藏夹 & 偏好持久化** | 跨会话持久化保存到 `${PLUGIN_DATA}/state.json` | • 收藏常用工作区/目录一键直达<br>• 可自由配置双击文件动作(定位 / 默认打开)与双击文件夹动作(进入 / 定位)<br>• 实时同步 Antigravity 明暗主题 |

---

## 架构与工作原理

基于 **MCP(Model Context Protocol)+ MCP Apps(SEP-1865)** 协议,运行时零外部依赖:

```mermaid
flowchart LR
  Agent["Agent / Always-On 规则"] -->|"stdio JSON-RPC (node)"| Server["零依赖 MCP Server<br/>server/index.mjs"]
  Server -->|"structuredContent"| Host["Antigravity 2.0 宿主"]
  Server -->|"ui://antigravity-win-explorer/*.html"| Host
  Host -->|"隔离 iframe + 主题变量"| UI["内嵌文件卡片 / 侧边栏浏览器<br/>dist/inline.html & explorer.html"]
  UI -->|"tools/call (app-only)"| Server
  Server -->|"explorer.exe /select, / Start-Process / wt.exe"| Win["Windows 资源管理器 / 默认程序 / 终端"]
```

- **无需 Bash**:`mcp_config.json` 直接调用 `node ${PLUGIN_ROOT}/server/index.mjs --data_dir=${PLUGIN_DATA}`。
- **注入防护**:Windows 默认程序打开与终端启动均通过环境变量向 `Start-Process -LiteralPath` 传参(绝不使用 `shell: true` 拼接命令),天然兼容中文路径、空格、括号及特殊字符。
- **预构建单文件 UI**:`dist/inline.html` 与 `dist/explorer.html` 已打包 `@modelcontextprotocol/ext-apps` 并提交至仓库,满足 Antigravity 严格 CSP 要求,安装即用。

---

## 快速安装(Windows 零构建)

> **环境要求**:Google Antigravity 2.0、Node.js(`v18+`)。已内置预构建 UI,**无需执行 `npm install`**。

### 方式一:Git 克隆直接安装(推荐)

打开 PowerShell,直接克隆到 Antigravity 全局插件目录:

```powershell
git clone https://github.com/tino0190/antigravity-win-explorer.git "$env:USERPROFILE\.gemini\config\plugins\antigravity-win-explorer"
```

### 方式二:使用 PowerShell 安装脚本

下载或克隆本仓库后,在仓库根目录运行:

```powershell
powershell -NoProfile -ExecutionPolicy Bypass -File .\install.ps1
```

> 如需卸载,可运行 `powershell -NoProfile -ExecutionPolicy Bypass -File .\uninstall.ps1`,或在 Antigravity 的 **Skills & Customizations → Plugins** 页面直接卸载。

### 安装后如何使用(无需重启 Antigravity)

Antigravity 会自动发现 `~/.gemini/config/plugins/` 下的新插件:

1. **打开侧边栏浏览器**:点击右侧辅助栏的 **`+`** 按钮 → 选择 **`Win 资源管理器`**(也可从左侧全局导航栏打开全屏视图)。
2. **体验聊天内嵌卡片**:下一轮对话让 AI 生成任何文档/脚本,回复末尾会自动附上文件定位卡片;你也可以直接说:
   - *“用文件卡片展示当前目录下的主要文件”*
   - *“打开 Win 资源管理器看看最近的对话产出”*
3. **工作区级规则(可选)**:如需在特定项目中强制提醒出卡,可将 `examples/.agents/rules/win-explorer-inline-card.md` 复制到项目的 `.agents/rules/` 目录。

---

## 目录结构

```text
antigravity-win-explorer/
├── plugin.json                              # Antigravity 插件清单
├── mcp_config.json                          # 原生 node 启动的 stdio MCP 配置
├── install.ps1 / uninstall.ps1              # Windows 一键安装与卸载脚本
├── README.md / README.en.md                 # 中英文说明文档
├── LICENSE                                  # MIT 协议
├── assets/
│   └── logo.svg                             # 自适应明暗主题矢量图标
├── rules/
│   └── AGENTS.md                            # 插件内置全局规则:产出文件后自动展示卡片
├── examples/.agents/rules/
│   └── win-explorer-inline-card.md          # 可选工作区规则模板
├── server/
│   └── index.mjs                            # 零依赖 Node.js MCP Server
├── dist/
│   ├── inline.html                          # 预构建单文件内嵌卡片 UI
│   └── explorer.html                        # 预构建单文件侧边栏浏览器 UI
├── src/                                     # UI 源码(使用 @modelcontextprotocol/ext-apps)
├── scripts/
│   └── build-ui.mjs                         # esbuild 单文件打包脚本
└── test/
    └── smoke.mjs                            # MCP stdio 端到端冒烟测试
```

---

## 安全与隐私说明

- **纯本地运行**:插件不发起任何外部网络请求,所有文件扫描与打开操作均在本地完成。
- **无破坏性工具**:仅提供只读目录浏览、在资源管理器中定位、默认程序打开与终端打开,不暴露任何删除或覆写用户文件的工具。
- **防命令注入**:所有系统调用均使用 `spawn` / `execFile` 配合 `-LiteralPath` 与环境变量传参,杜绝 Shell 注入风险。

---

## 本地开发与构建

如果你修改了 `src/` 下的前端源码,可重新构建 `dist/` 并运行冒烟测试:

```powershell
npm.cmd install
npm.cmd run build:ui
npm.cmd test
```

---

## License

基于 [MIT License](./LICENSE) 开源发布。