Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions README-zh.md
Original file line number Diff line number Diff line change
Expand Up @@ -202,6 +202,7 @@ ai-devkit init --template ./senior-engineer.yaml
| [Cursor](https://cursor.sh/) | yes | — |
| [GitHub Copilot](https://code.visualstudio.com/) | yes | — |
| [Antigravity](https://antigravity.google/) | yes | — |
| [Antigravity CLI](https://antigravity.google/) | yes | yes |
| [Amp](https://ampcode.com/) | yes | — |
| [Kilo Code](https://github.com/Kilo-Org/kilocode) | yes | — |
| [Roo Code](https://roocode.com/) | testing | — |
Expand Down
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -205,6 +205,7 @@ One `.ai-devkit.json` configures all of them. Add a new agent to your team witho
| [Cursor](https://cursor.sh/) | yes | — |
| [GitHub Copilot](https://code.visualstudio.com/) | yes | — |
| [Antigravity](https://antigravity.google/) | yes | — |
| [Antigravity CLI](https://antigravity.google/) | yes | yes |
| [Amp](https://ampcode.com/) | yes | — |
| [Kilo Code](https://github.com/Kilo-Org/kilocode) | yes | — |
| [Roo Code](https://roocode.com/) | testing | — |
Expand Down
39 changes: 39 additions & 0 deletions docs/ai/design/feature-antigravity-cli-adapter.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
---
phase: design
title: "Antigravity CLI Adapter in @ai-devkit/agent-manager - Design"
feature: antigravity-cli-adapter
description: Architecture for the Antigravity (`agy`) CLI detection adapter, launch map entry, and CLI wiring
---

# Design: Antigravity CLI Adapter for @ai-devkit/agent-manager

## Responsibilities
- `AntigravityCliAdapter`: discover running `agy` processes, resolve each to its conversation via `cache/last_conversations.json`, read its transcript, emit `AgentInfo`, and enumerate conversations — parsing kept inline like the other recent adapters.
- `AGENTS.antigravity_cli`: launch command (`agy`) + `ps` matcher.
- CLI/channel: register the adapter, label the type, validate `--type`.

## Data model
Reuse `AgentAdapter`, `AgentInfo`, `AgentStatus`, `AgentType`, `SessionSummary`. `AgentType` gains `'antigravity_cli'`.

- `cache/last_conversations.json` (at the CLI home root): `{ <cwd>: <conversationId> }`. The live process cwd is the join key; there is no pid in this file, so `proc.cwd` is the lookup key.
- `brain/<conversationId>/.system_generated/logs/transcript.jsonl`: `{ source, type, created_at, content }` per line. `content` is a string or an array of `{ type: "text", text }` blocks. User prompt = text inside `<USER_REQUEST>...</USER_REQUEST>` of a `type: "USER_INPUT"` record; assistant reply = `type: "PLANNER_RESPONSE"`. Other MODEL records (tool calls like RUN_COMMAND) and `SYSTEM` records are execution detail, skipped unless verbose.

Normalized into `AgentInfo`: `name` ← `generateAgentName(projectPath, pid)`; `projectPath` ← cwd from the registry (else process cwd); `sessionId` ← the conversation id; `summary` ← last `<USER_REQUEST>`; `status` ← time-threshold + last-transcript-role heuristic; `sessionFilePath` ← the conversation's `transcript.jsonl`.

## Component breakdown
1. `packages/agent-manager/src/adapters/AntigravityCliAdapter.ts` (new, self-contained)
- `canHandle`: argv[0] basename `agy`/`agy.exe`.
- `detectAgents`: take `agy` processes from the shared `AgentDetectionContext` snapshot (falling back to `captureProcessSnapshot(processNames)`); per process resolve cwd → conversationId via `readRegistry()`, read the transcript; live processes with no conversation → process-only RUNNING agents.
- inline parsing: `readRegistry`, `readConversationCwds`, `readSession`, `parseTranscript` (`<USER_REQUEST>` prompts + `PLANNER_RESPONSE` replies), `determineStatus`, `getConversation`.
- `listSessions`: enumerate `brain/<id>/`, attach a cwd from the inverted registry when it names that conversation, parse each transcript, strict `cwd` filter.
2. `AntigravityCliAdapter.test.ts` (new): fixtures from the captured real format.
3. Exports, launch map, CLI registration, labels, validation.

## Design decisions
- Resolve a live process's conversation from `cache/last_conversations.json` (cwd → id), not from cwd-encoded session dirs; there is one current conversation per workspace.
- Enumerate history from `brain/`, not from that cache. The cache names only the *current* conversation of each workspace, so listing from it hides every older conversation as soon as a new one starts. `brain/` is the full set.
- Accept partial cwd coverage as the cost of that: Antigravity records the workspace nowhere in the conversation itself (neither `transcript.jsonl` nor `transcript_full.jsonl` contains it, and `conversations/<id>.db` keeps its metadata in opaque protobuf blobs), so a conversation the cache no longer names gets `cwd: ''` and surfaces under `agent sessions --all`. Listing a session with an unknown cwd beats not listing it at all.
- Parse `transcript.jsonl` for conversation and summary; take the prompt inside `<USER_REQUEST>...</USER_REQUEST>`.
- `sessionFilePath` points at `transcript.jsonl` so the console's `fs.stat().mtime` cache invalidation tracks conversation growth.
- Keep parsing resilient — a missing/malformed transcript skips the session; adapter-level failures return empty so other adapters still render.
- Independent of the `antigravity` IDE environment (same split as `gemini_cli` vs `gemini`).
30 changes: 30 additions & 0 deletions docs/ai/implementation/feature-antigravity-cli-adapter.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
---
phase: implementation
title: "Antigravity CLI Adapter in @ai-devkit/agent-manager - Implementation"
feature: antigravity-cli-adapter
description: Implementation notes for the Antigravity (`agy`) CLI adapter
---

# Implementation: Antigravity CLI Adapter

## What shipped
- `packages/agent-manager/src/adapters/AntigravityCliAdapter.ts` — self-contained adapter.
- `AgentType`/`StartableAgentType` gain `'antigravity_cli'`; `AGENTS.antigravity_cli = { command: 'agy', matches: matchArgv0('agy') }`; exported from `adapters/index.ts` and `index.ts`.
- CLI: registered in `commands/agent.ts` and `services/channel/channel-runner.ts`; `TYPE_LABELS.antigravity_cli = 'Antigravity CLI'`; `--type` help + `VALID_AGENT_TYPES` updated.

## Notes
- Home: `~/.gemini/antigravity-cli/` (override via `ANTIGRAVITY_CLI_HOME`). A live process is resolved to its conversation via `cache/last_conversations.json` (`{cwd:id}`); the process cwd is the join key.
- `detectAgents` reads `agy` processes from the shared `AgentDetectionContext` snapshot and declares `processNames = ['agy']`, so the manager's single `ps` pass covers this adapter too.
- `listSessions` enumerates `brain/<id>/` and attaches a cwd only when the (inverted) cache still names that conversation — the cache holds one entry per workspace, so older conversations of a cwd are absent from it and would otherwise never be listed. Conversations without a cwd get `''` and show under `agent sessions --all`; nothing else on disk records the workspace (see requirements).
- Parsing: `transcript.jsonl` → user prompts are the text inside `<USER_REQUEST>...</USER_REQUEST>` of `type:'USER_INPUT'` records; the assistant reply is a `type:'PLANNER_RESPONSE'` record; other MODEL records (tool calls like RUN_COMMAND) and `SYSTEM` records are skipped unless verbose. `lastActive` is the newest record `created_at` (else file mtime).
- `AgentInfo.sessionFilePath` / `SessionSummary.sessionFilePath` point at `transcript.jsonl`; `getConversation` accepts the file path, a session dir, or a bare conversation id.

## Patterns & best practices
- Mirror `GrokCliAdapter`'s shape (registry JSON + transcript JSONL), parsing kept **inline** like the other recent adapters.
- Fail soft: a missing/malformed `transcript.jsonl` skips the session; adapter-level failures return empty so other adapters still render.

## Error handling
- Missing `cache/last_conversations.json` → empty registry, no throw; `listSessions` still lists `brain/` with unknown cwds.
- Missing `brain/` → `listSessions` returns `[]`; a `brain/<id>/` with no transcript is skipped.
- Mapped conversation with no transcript → process-only RUNNING agent.
- A live `agy` process whose cwd is not in the registry → process-only RUNNING agent.
27 changes: 27 additions & 0 deletions docs/ai/planning/feature-antigravity-cli-adapter.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
---
phase: planning
title: "Antigravity CLI Adapter in @ai-devkit/agent-manager - Planning"
feature: antigravity-cli-adapter
description: Task plan for the Antigravity (`agy`) CLI adapter
---

# Planning: Antigravity CLI Adapter

## Key facts
- Conversation source: `brain/<id>/.system_generated/logs/transcript.jsonl`. Live cwd→id from `cache/last_conversations.json`.
- History source: `brain/` itself. The cache keeps one conversation per workspace, so it is a live-process join table, not a session index.
- Binary `agy`; home `~/.gemini/antigravity-cli/` (override `ANTIGRAVITY_CLI_HOME`).

## Tasks
- [x] Capture real layout: `agy -p` produces `cache/last_conversations.json` (`{cwd:id}`) + `brain/<id>/.system_generated/logs/transcript.jsonl`.
- [x] Confirm schemas (`{cwd:id}` registry; transcript `{source,type,created_at,content}` with `<USER_REQUEST>` prompts and `MODEL` responses).
- [x] Implement self-contained `AntigravityCliAdapter` (`canHandle`, `detectAgents` via registry, inline `transcript.jsonl` parsing, `getConversation`, `listSessions`) + unit tests.
- [x] Add `'antigravity_cli'` to `AgentType`/`StartableAgentType`; `AGENTS.antigravity_cli` launch map; exports.
- [x] Wire CLI: register in `agent` command + channel runner; `TYPE_LABELS`; `--type` help; `VALID_AGENT_TYPES`.
- [x] Update cli test fixtures (adapter mock, registerAdapter counts, `STARTABLE_AGENT_TYPES`, `--type` list).
- [x] Review follow-up: list history from `brain/` so older conversations of a cwd are not hidden by the cache; keep the cache as the cwd source it actually is.

## Risks
- Risk: Antigravity CLI schema evolves. Mitigation: defensive parsing, fixtures for partial/malformed inputs.
- Risk: `proc.cwd` unavailable for some processes → falls back to process-only agent (still listed).
- Risk: a listed conversation has no discoverable cwd (the cache moved on and nothing else records it) → listed with `cwd: ''`, reachable via `agent sessions --all` rather than a cwd-scoped listing.
33 changes: 33 additions & 0 deletions docs/ai/requirements/feature-antigravity-cli-adapter.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
---
phase: requirements
title: "Antigravity CLI Adapter in @ai-devkit/agent-manager - Requirements"
feature: antigravity-cli-adapter
description: Detect, list, and manage Google's Antigravity (`agy`) CLI agents in the ai-devkit control plane
---

# Requirements: Antigravity CLI Adapter for @ai-devkit/agent-manager

## Problem
ai-devkit already configures the Antigravity **IDE** via the `antigravity` environment, but it cannot see or control the Antigravity **CLI** (`agy`). Running `agy` sessions do not show in `agent list`, `agent sessions`, the console, or `agent send`. This mirrors how `gemini` (env) and `gemini_cli` (adapter) are separate; Antigravity needs its CLI adapter.

## Goals
- Detect running `agy` processes and surface them in `agent list` / console.
- List historical Antigravity CLI conversations in `agent sessions --type antigravity_cli` — every conversation on disk, not only the current one per workspace.
- Read a conversation transcript for `agent detail` / `agent send` targeting.
- Keep the existing `antigravity` IDE environment untouched.

## Non-goals
- Launching is data-driven from `AGENTS`; no bespoke start flow.
- No changes to the Antigravity IDE environment or its skill paths.

## On-disk facts (verified against `agy`, Google Gemini-family CLI)
- Home: `~/.gemini/antigravity-cli/` (`ANTIGRAVITY_CLI_HOME` overrides it).
- `cache/last_conversations.json`: a `{ "<cwd>": "<conversationId>" }` map of the current conversation per workspace. This is the join key from a live process's cwd to its conversation. It is *not* a session index: starting a new conversation in a workspace overwrites that workspace's entry, so it names at most one conversation per cwd.
- `brain/` holds every conversation, current or not — it is the only complete list. On a dev machine with five conversations, the cache named one.
- No file outside that cache records a conversation's workspace: `transcript.jsonl` and `transcript_full.jsonl` contain no cwd, and `conversations/<id>.db` stores its metadata in protobuf blobs (`trajectory_metadata_blob`, `steps.metadata`) with no readable path column.
- Transcript: `brain/<conversationId>/.system_generated/logs/transcript.jsonl`, newline-delimited `{ source, type, created_at, content }`. User turns are `type: "USER_INPUT"` with the prompt inside `<USER_REQUEST>...</USER_REQUEST>`; the model reply is a `type: "PLANNER_RESPONSE"` record. Other MODEL records (tool calls such as RUN_COMMAND) and `SYSTEM` records (conversation history, checkpoints) are non-conversational.
- The `agy` binary's argv[0] basename is `agy`.

## Acceptance
- Unit tests cover: `canHandle`, no-process, registry cwd→id resolution, process-only fallback, missing transcript, transcript conversation extraction, status mapping, `listSessions` + cwd filter, and conversations the cache no longer names.
- Verified end-to-end against a real `agy 0.x` session on disk (`agent-manager:test` and `cli:test` pass).
32 changes: 32 additions & 0 deletions docs/ai/testing/feature-antigravity-cli-adapter.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
---
phase: testing
title: "Antigravity CLI Adapter in @ai-devkit/agent-manager - Testing"
feature: antigravity-cli-adapter
description: Test strategy and coverage for the Antigravity (`agy`) CLI adapter
---

# Testing Strategy: Antigravity CLI Adapter

## Unit Tests (`AntigravityCliAdapter.test.ts`)
- [x] Exposes `antigravity_cli` type
- [x] `canHandle` true for `agy` (plain + full path + args); false for non-agy / arg-only matches
- [x] `detectAgents` returns `[]` with no processes
- [x] Resolves the conversation via `last_conversations.json` (cwd → id)
- [x] Process-only RUNNING fallback when the cwd is not in the registry
- [x] Process-only when the mapped conversation has no transcript
- [x] `getConversation` maps `USER_INPUT` (`<USER_REQUEST>`) + `PLANNER_RESPONSE` records to roles; excludes MODEL tool calls (RUN_COMMAND) except in verbose; skips malformed lines
- [x] `getConversation` excludes `SYSTEM` records unless verbose
- [x] Status: WAITING on trailing MODEL turn; RUNNING on trailing USER_INPUT; IDLE past threshold
- [x] Agent summary is the last user request
- [x] `listSessions` returns `[]` without a `brain/` dir; attaches the cwd the cache names; applies the cwd filter
- [x] `listSessions` lists conversations the cache no longer names (older conversations of the same cwd), with `cwd: ''`
- [x] `listSessions` skips `brain/` entries with no transcript

## Integration / launch map
- [x] `AGENTS.antigravity_cli.command === 'agy'`; registered in `agent` command + channel runner; `STARTABLE_AGENT_TYPES` includes `antigravity_cli`; `--type antigravity_cli` accepted.

## End-to-End (verified against a real `agy` install)
- [x] `listSessions()` against the real `~/.gemini/antigravity-cli` lists all 5 on-disk conversations (the cache named 1) with `firstUserMessage` and the `transcript.jsonl` `sessionFilePath`; the 1 the cache still names carries its `cwd`, and `listSessions({ cwd })` returns exactly that one.
- [x] `getConversation()` against the real transcript returns the `[{user}, {assistant}]` turns (`<USER_REQUEST>` extracted, `MODEL` response, `SYSTEM` skipped).
- [x] `detectAgents()` with a live `agy` process + real registry resolves the cwd, picks the conversation, and surfaces `{type:"antigravity_cli", projectPath:<repo>, summary:<prompt>}`.
- [x] Regression: full `agent-manager` and `cli` suites pass.
Loading
Loading