# 拾音接 Antigravity CLI，要先讓 agy 不能動手

> 拾音 5.4.0 把 Google 的 Antigravity CLI（agy）加成會議紀錄的整理工具。agy 本來會讀檔、改檔、跑指令，拾音只要它回一份 JSON，所以每次都用官網沒寫的 --settings 帶拒絕規則，跑完再照 conversation_id 刪掉它留下的對話檔。

- 網址：https://www.weibuilds.com/blog/antigravity-agy-cli/
- 作者：weiwei
- 日期：2026-11-27
- 主題：AI 與自動化
- 標籤：shiyin、antigravity、agy、gemini、cli

11 月 27 日 Threads 上有使用者許願要 Antigravity。拾音當天的 5.4.0 就把它加進整理工具，跟 Claude Code、Codex 並列。Antigravity CLI（指令是 `agy`）是 Google 的代理式命令列工具，用 Google 帳號登入，免費帳號每週有用量額度。麻煩在它是「代理」：本來就會讀檔、改檔、執行指令、上網，拾音只要它讀完逐字稿、回一份 JSON。下面的行為都是 agy 1.5.18 實測的。

## 送進去、拿出來

<figure>
<svg class="diagram" viewBox="0 0 760 270" role="img" aria-label="拾音呼叫 agy 的一次流程。先建一個暫存資料夾，裡面放 schema.json、settings.json 和一個空的 workspace 資料夾，agy 的工作目錄就是這個空資料夾。拾音從標準輸入送一行 stream-json，內容是提示詞加上 schema 說明，送完關掉輸入。agy 逐行輸出：第一行 step_update 就帶著 conversation_id，拾音先記下來；最後一行 result，狀態是 SUCCESS 時取 structured_output。跑完不論成功、失敗、逾時或取消，都照 conversation_id 刪掉 agy 留在家目錄的對話檔，再刪掉整個暫存資料夾。" xmlns="http://www.w3.org/2000/svg">
  <defs>
    <marker id="ag-ar" viewBox="0 0 10 10" refX="9" refY="5" markerWidth="7" markerHeight="7" orient="auto"><path d="M0 0L10 5L0 10z" fill="var(--ink-2)"/></marker>
  </defs>
  <g font-size="13" font-family="inherit" fill="var(--ink)">
    <rect x="20" y="16" width="230" height="110" rx="10" fill="none" stroke="var(--ink-2)" stroke-dasharray="5 4"/>
    <text x="34" y="36" font-size="12" fill="var(--ink-2)">暫存資料夾（用完整個刪）</text>
    <text x="40" y="62">schema.json</text>
    <text x="40" y="84">settings.json（拒絕規則）</text>
    <text x="40" y="106">workspace/（空的，工作目錄）</text>
    <rect x="300" y="16" width="200" height="52" rx="6" fill="var(--paper-2)" stroke="var(--rule)"/>
    <text x="400" y="37" text-anchor="middle" font-weight="600">stdin 送一行</text>
    <text x="400" y="56" text-anchor="middle" font-size="12" fill="var(--ink-2)">提示詞＋schema 說明</text>
    <line x1="500" y1="42" x2="548" y2="42" stroke="var(--ink-2)" stroke-width="1.6" marker-end="url(#ag-ar)"/>
    <rect x="550" y="16" width="190" height="52" rx="6" fill="var(--topic-ai)"/>
    <text x="645" y="37" text-anchor="middle" font-weight="600" fill="var(--paper)">agy</text>
    <text x="645" y="56" text-anchor="middle" font-size="12" fill="var(--paper)">stream-json 進、出</text>
    <line x1="645" y1="68" x2="645" y2="96" stroke="var(--ink-2)" stroke-width="1.6" marker-end="url(#ag-ar)"/>
    <rect x="300" y="98" width="440" height="80" rx="6" fill="var(--paper-2)" stroke="var(--rule)"/>
    <text x="316" y="122" font-size="12" fill="var(--ink-2)">第一行 step_update：帶 conversation_id，先記下來</text>
    <text x="316" y="144" font-size="12" fill="var(--ink-2)">……</text>
    <text x="316" y="166" font-size="12" fill="var(--ink-2)">最後一行 result：SUCCESS 取 structured_output</text>
    <line x1="520" y1="178" x2="520" y2="206" stroke="var(--ink-2)" stroke-width="1.6" marker-end="url(#ag-ar)"/>
    <rect x="300" y="208" width="440" height="50" rx="6" fill="none" stroke="var(--accent)"/>
    <text x="520" y="230" text-anchor="middle" font-weight="600">成功、失敗、逾時、取消都一樣</text>
    <text x="520" y="248" text-anchor="middle" font-size="12" fill="var(--ink-2)">照 conversation_id 刪掉 agy 留下的對話檔</text>
  </g>
</svg>
<figcaption>逐字稿走標準輸入，不放在命令列參數裡，Windows 的命令列也放不下一整場會議。</figcaption>
</figure>

輸入用 stream-json：從標準輸入送一行 `{"event":"user",…}`，送完關掉，agy 跑完這一輪就結束。格式要求用 `--json-schema`，但只給這個參數時，第一輪模型會自己發明欄位，最後一輪才把東西硬塞進 schema，欄位裡出現整段 JSON 字串。所以我照 OpenAI 相容 API 的退回做法，在提示詞最後再附上 schema 本身，請它只回符合 schema 的 JSON。

agy 自己的系統提示詞（工具說明）約 1.1 萬 token，每次都算進使用者的額度；一場很短的整理約 8 秒。

## 用 --settings 把工具全部擋掉

`agy --help` 裡有個 `--settings`，只在這次執行有效、不會存檔，官網文件沒有寫。拾音每次都帶：

```json
{"toolPermission":"strict","agentMode":"","permissions":{"deny":["read_file(*)","write_file(*)","command(*)","unsandboxed(*)","read_url(*)","execute_url(*)","download_url(*)","mcp(*)"]}}
```

<figure>
<svg class="diagram" viewBox="0 0 760 260" role="img" aria-label="agy 收到一個工具動作時的判斷順序。最先看拒絕規則，拾音用 --settings 帶的規則擋掉讀檔、寫檔、執行指令、沒有沙盒的執行、讀網址、執行網址、下載和 MCP，符合就拒絕，使用者自己的允許規則也蓋不過。沒被擋到的動作，因為 toolPermission 是 strict，每個都要人核准，背景執行沒有人能按，也當成拒絕。實測要它建檔、執行 echo、讀 /etc/hosts，三個都回 Permission denied。擋不掉的是 agy 自己會讀的 ~/.gemini 規則檔，例如 AGENTS.md 和 GEMINI.md。" xmlns="http://www.w3.org/2000/svg">
  <defs>
    <marker id="ag2-ar" viewBox="0 0 10 10" refX="9" refY="5" markerWidth="7" markerHeight="7" orient="auto"><path d="M0 0L10 5L0 10z" fill="var(--ink-2)"/></marker>
  </defs>
  <g font-size="13" font-family="inherit" fill="var(--ink)">
    <rect x="20" y="20" width="190" height="52" rx="6" fill="var(--paper-2)" stroke="var(--rule)"/>
    <text x="115" y="42" text-anchor="middle" font-weight="600">模型想用一個工具</text>
    <text x="115" y="60" text-anchor="middle" font-size="12" fill="var(--ink-2)">讀檔、跑指令、上網…</text>
    <line x1="210" y1="46" x2="258" y2="46" stroke="var(--ink-2)" stroke-width="1.6" marker-end="url(#ag2-ar)"/>
    <rect x="260" y="20" width="250" height="52" rx="6" fill="var(--topic-ai)"/>
    <text x="385" y="42" text-anchor="middle" font-weight="600" fill="var(--paper)">一、deny 規則（最優先）</text>
    <text x="385" y="60" text-anchor="middle" font-size="12" fill="var(--paper)">--settings 帶的，使用者的 allow 蓋不過</text>
    <line x1="510" y1="46" x2="558" y2="46" stroke="var(--ink-2)" stroke-width="1.6" marker-end="url(#ag2-ar)"/>
    <text x="534" y="38" text-anchor="middle" font-size="12" fill="var(--ink-2)">符合</text>
    <rect x="560" y="20" width="180" height="52" rx="6" fill="none" stroke="var(--accent)"/>
    <text x="650" y="42" text-anchor="middle" font-weight="600">拒絕</text>
    <text x="650" y="60" text-anchor="middle" font-size="12" fill="var(--ink-2)">Permission denied</text>
    <line x1="385" y1="72" x2="385" y2="110" stroke="var(--ink-2)" stroke-width="1.6" marker-end="url(#ag2-ar)"/>
    <text x="397" y="96" font-size="12" fill="var(--ink-2)">沒被擋到</text>
    <rect x="260" y="112" width="250" height="52" rx="6" fill="var(--paper-2)" stroke="var(--rule)"/>
    <text x="385" y="134" text-anchor="middle" font-weight="600">二、toolPermission: strict</text>
    <text x="385" y="152" text-anchor="middle" font-size="12" fill="var(--ink-2)">每個動作都要人核准</text>
    <path d="M510 138 H650 V74" fill="none" stroke="var(--ink-2)" stroke-width="1.6" marker-end="url(#ag2-ar)"/>
    <text x="580" y="130" text-anchor="middle" font-size="12" fill="var(--ink-2)">背景執行沒人按</text>
    <rect x="20" y="196" width="720" height="48" rx="6" fill="none" stroke="var(--rule)" stroke-dasharray="5 4"/>
    <text x="380" y="217" text-anchor="middle" font-size="12" fill="var(--ink-2)">實測：建檔、執行 echo、讀 /etc/hosts，三個都被拒絕，工作目錄沒有多出檔案</text>
    <text x="380" y="236" text-anchor="middle" font-size="12" fill="var(--ink-2)">擋不掉：~/.gemini/ 的 AGENTS.md、GEMINI.md 規則檔，agy 照樣會讀</text>
  </g>
</svg>
<figcaption>兩層都在，就算以後多了新的工具種類沒寫進 deny，也還有 strict 擋著。</figcaption>
</figure>

`strict` 是每個工具動作都要人核准，背景執行沒有人能按，就當成拒絕。`deny` 規則在任何模式都最優先，使用者自己設的允許規則也蓋不過。`agentMode` 給空字串是一般模式；沒給時，背景執行預設是會自動核准改檔和指令的 auto。我實際叫它在工作目錄建檔、執行 `echo`、讀 `/etc/hosts`，三個都回「Permission denied … Matches user-configured deny rule」，工作目錄也沒有多出檔案。

| 試過的做法 | 為什麼不用 |
|---|---|
| 換 `HOME` 隔離 | 登入綁在家目錄，換了就是沒登入 |
| 改使用者的 `settings.json` | 會改到他自己在專案裡用 agy 的行為 |
| `--mode plan` | 只在提示詞前面加「先規劃」，不擋任何工具 |

這個參數不在文件裡，哪天 agy 拿掉它，會因為不認得參數直接失敗，不會變成沒有限制地執行。擋不掉的是 `~/.gemini/` 底下的規則檔（`AGENTS.md`、`GEMINI.md`），agy 照樣會讀，使用者自己寫的規則可能影響整理結果。

## 不留紀錄要自己刪

Claude Code 有 `--no-session-persistence`，Codex 有 `--ephemeral`，agy 沒有對應的參數。每跑一次，`~/.gemini/antigravity-cli/` 底下就多一個 `conversations/<id>.db`（整段對話，一次約 480 KB）和 `brain/<id>/` 資料夾，放著不管，每場會議的逐字稿都會留在 agy 的歷史裡。

stream-json 的第一行就帶著 `conversation_id`，拾音一讀到就先記下來，就算 agy 中途失敗、沒有輸出最後的 result，也知道要刪哪一個。跑完不論結果，照這個 id 刪掉那兩樣，id 不是 UUID 就不動。`conversation_summaries.db` 我不碰，那是 agy 的 SQLite，使用者可能正開著 agy，裡面那一列的預覽只有訊息開頭約 100 字，拾音的訊息開頭是系統提示詞，不是會議內容。

用示範會議實測，整理 42 秒完成，摘要、待辦、每人重點都在，agy 的對話資料夾前後都是 6 個檔。還沒驗到的是額度用完時 agy 回什麼訊息，目前沿用其他工具的判斷字樣。
