Initial commit — Antigravity plugin v0.1.0

Plugin Claude Code miroir du plugin codex officiel d'OpenAI, mais
pour Google Antigravity (agy CLI). Headless via:

  agy --print --dangerously-skip-permissions --print-timeout 10m

Includes:
- 1 forwarder agent (antigravity-rescue)
- 5 slash commands (setup, rescue, status, result, cancel)
- 3 internal skills (cli-runtime, result-handling, gemini-prompting)
- agy-companion.mjs runtime (task / setup / status / result / cancel)
- marketplace.json for `/plugin marketplace add`

Tested: setup OK, foreground task OK, background workflow OK
(except OAuth refresh which requires interactive TTY).

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
This commit is contained in:
2026-05-19 23:57:41 +02:00
commit e8ad489f36
14 changed files with 869 additions and 0 deletions

View File

@@ -0,0 +1,49 @@
---
name: antigravity-cli-runtime
description: Internal helper contract for calling the agy-companion runtime from Claude Code
user-invocable: false
---
# Antigravity Runtime
Use this skill only inside the `antigravity:antigravity-rescue` subagent.
Primary helper:
- `node "${CLAUDE_PLUGIN_ROOT}/scripts/agy-companion.mjs" task "<raw arguments>"`
Execution rules:
- The rescue subagent is a forwarder, not an orchestrator. Its only job is to invoke `task` once and return that stdout unchanged.
- Prefer the helper over hand-rolled `agy` strings, direct CLI calls, or any other Bash activity.
- Do not call `setup`, `status`, `result`, or `cancel` from `antigravity:antigravity-rescue`.
- Use `task` for every rescue request, including diagnosis, planning, research, and explicit fix requests.
- You may use the `gemini-prompting` skill to rewrite the user's request into a tighter Antigravity prompt before the single `task` call.
- That prompt drafting is the only Claude-side work allowed. Do not inspect the repo, solve the task yourself, or add independent analysis outside the forwarded prompt text.
Command selection:
- Use exactly one `task` invocation per rescue handoff.
- If the forwarded request includes `--background`, forward it as `--background` to the helper.
- If the forwarded request includes `--wait`, treat that as a hint to NOT use `--background` (foreground). Strip `--wait` from the task text.
- If the forwarded request includes `--resume`, strip that token from the task text and add `--resume` to the helper invocation. This becomes `--continue` for the agy CLI.
- If the forwarded request includes `--fresh`, strip that token and do not add `--resume`.
- If the forwarded request includes `--sandbox`, pass `--sandbox` through to the helper (it enables agy's sandbox mode with terminal restrictions).
- If the forwarded request includes `--add-dir <path>`, pass `--add-dir <path>` through to the helper (it adds a workspace directory).
- If the forwarded request includes `--timeout <value>`, pass it through (format: `10m` or `300s`). Default foreground timeout is 10 minutes; background is 30 minutes.
Bash invocation pattern:
```bash
node "${CLAUDE_PLUGIN_ROOT}/scripts/agy-companion.mjs" task [--background] [--resume] [--sandbox] [--add-dir <p>] [--timeout 10m] "<the user task text>"
```
Safety rules:
- Always quote the prompt text to preserve spaces and special characters.
- Preserve the user's task text as-is apart from stripping routing flags.
- Do not inspect the repository, read files, grep, monitor progress, poll status, fetch results, cancel jobs, summarize output, or do any follow-up work of your own.
- Return the stdout of the `task` command exactly as-is.
- If the Bash call fails or Antigravity cannot be invoked, return nothing.
Headless authorization:
- Under the hood, the helper invokes `agy --print --dangerously-skip-permissions --print-timeout <T>`.
- `--dangerously-skip-permissions` auto-approves all tool permission requests (necessary for headless work).
- `--print` runs a single prompt non-interactively and prints the response.
- This is the safe, documented headless mode of agy (per `agy --help`).

View File

@@ -0,0 +1,52 @@
---
name: antigravity-result-handling
description: Internal guidance for presenting Antigravity (Gemini) helper output back to the user
user-invocable: false
---
# Antigravity Result Handling
This skill governs how Claude should present output that comes back from the `agy-companion.mjs` helper.
## Foreground task
When a foreground `task` returns:
1. The stdout is the **raw Gemini response** from `agy --print`.
2. **Return it verbatim to the user.** Do not paraphrase, summarize, restructure, or add commentary.
3. If the response is empty or the command exited non-zero, tell the user one short sentence: *"Antigravity returned nothing — try /antigravity:status or rerun with /antigravity:setup."*
4. If the response mentions errors that suggest agy is not authenticated, suggest running `agy login` in a terminal.
## Background task
When a background `task` is started, the helper prints something like:
```
[antigravity] Job started in background.
job id : agy-xxxx-xxxxx
pid : 12345
log file : /Users/.../jobs/agy-xxxx.log
status : node "..." status agy-xxxx-xxxxx
result : node "..." result agy-xxxx-xxxxx
```
Present this to the user as-is. Do not block on polling.
## Status / result
When the user runs `/antigravity:status`, the helper prints job metadata (pid, started, log path, prompt preview). When they run `/antigravity:result`, the helper streams the full log. Return it verbatim.
## Streaming considerations
`agy --print` in headless mode often outputs the model's tokens as they arrive. The companion script streams them to stdout. Do not hold the output until the end — Claude can present it as it streams.
## Length
Antigravity responses can be long. Do not truncate or summarize unless the user explicitly asks for a summary. If the response is very long, mention at the end: *"(Antigravity response was N lines)"*.
## Errors
If the helper exits with a non-zero code:
- Exit code 124 = timeout. Tell the user the prompt timed out and suggest `--timeout 20m` or `--background`.
- Exit code 2 = invalid args. Show the user what was wrong.
- Other = unknown error. Pass through the stderr.

View File

@@ -0,0 +1,96 @@
---
name: gemini-prompting
description: Internal guidance for composing Antigravity (Gemini) prompts for coding, review, diagnosis, and research tasks inside the Antigravity Claude Code plugin
user-invocable: false
---
# Prompting Gemini through Antigravity
Antigravity wraps Google's Gemini model in a CLI. The model is verbose by default and tends to over-explain. To get great rescue/task output, follow these rules.
## 1. Be explicit and structured
Gemini works better when the request is well-structured. Use a header + numbered steps when possible:
```
TASK
Investigate why <X> fails on macOS but works on Linux.
CONTEXT
- Reproduces with `npm test` in /Users/.../my-project
- Failing test: src/utils.test.ts → "should hash file"
- Suspected root cause: BSD `sha256sum` not installed on macOS
WHAT I WANT
1. Root-cause confirmation (read the code, run the failing test if possible)
2. Concrete fix (with file diff)
3. Verification command
```
## 2. Tell it what NOT to do
Gemini tends to add tons of context, options, and alternatives. To keep responses tight:
```
CONSTRAINTS
- Do not propose multiple solutions — pick the best one.
- Do not explain what the code does at length. Focus on the fix.
- Do not write a README/CHANGELOG/migration guide.
- Output max 200 words of prose + the diff.
```
## 3. Provide file paths explicitly
Gemini has its own scratch workspace at `~/.gemini/antigravity-cli/scratch/`. To make it work on the user's actual repo, **always provide absolute paths** in the prompt:
```
Work in /Users/olivierdupont/Desktop/diversclaude/my-project/
Read src/utils.ts and src/utils.test.ts.
Apply the fix to src/utils.ts.
```
If the path is outside the default workspace, add the routing flag `--add-dir /path/to/project`.
## 4. Diagnosis vs. fix
Distinguish clearly between:
- **Diagnosis**: "Investigate and report. No edits."
- **Fix**: "Apply the fix directly to the files."
- **Plan**: "Write a plan but don't execute it."
Default behavior of `--dangerously-skip-permissions` is to allow file edits. If you want read-only behavior, say so explicitly in the prompt.
## 5. Resume vs. fresh
Gemini's `--continue` flag resumes the most recent session. Use it (via the runtime's `--resume` flag) when:
- Following up on a previous rescue
- Iterating on a draft fix
- Asking for more depth on the same investigation
Use a fresh session when:
- Completely new task, unrelated to previous
- The previous context is stale or wrong-headed
## 6. Antipatterns
- **Vague**: "Fix this bug" — what bug? where?
- **Too many sub-tasks**: keep one focused task per `task` call.
- **Asking for opinions**: Gemini's opinions are bland — ask for actions.
- **Trusting blindly**: ALWAYS read the resulting diff before committing.
## 7. Recommended boilerplate
```
TASK: <one-sentence outcome>
CONTEXT:
<3-8 bullets of what's known, file paths, what's been tried>
DELIVERABLE:
<file diffs, verification command, or specific answer>
CONSTRAINTS:
- Output max <N> lines.
- Do not modify files outside <list>.
- Do not refactor anything outside the immediate fix.
```