Skip to content

feat(agy): add Google Antigravity plugin, unified hook protocol, setup deployer, and transcript parser - #205

Open
bilersan wants to merge 6 commits into
ActiveMemory:mainfrom
bilersan:feat/agy-integration
Open

bilersan wants to merge 6 commits into
ActiveMemory:mainfrom
bilersan:feat/agy-integration

Conversation

@bilersan

@bilersan bilersan commented Nov 7, 2026

Copy link
Copy Markdown
Contributor

Summary

Closes #204

Adds first-class Google Antigravity (agy CLI and Antigravity IDE) integration to ctx as a peer to Claude Code, Codex, OpenCode, and Pi across four cohesive layers (AGY1–AGY4):

  1. Unified Hook Protocol in ctx system ([AGY1]):

    • Auto-detects Antigravity camelCase stdin hook payloads (conversationId, workspacePaths, transcriptPath, modelName, lastUserInput, toolCall, error) in entity.HookInput while preserving 100% backward compatibility with Claude Code (snake_case).
    • Resolves workspacePaths[0] (including file:// URIs) and executes os.Chdir(ws) + rc.Reset() in session.ReadInput before state.Initialized() or rc.RC() runs so global/plugin hooks locate the workspace's .context/ and .ctxrc.
    • Emits Antigravity-compliant stdout JSON ({"decision":"allow"|"deny"}, {"injectSteps":[...]}, {}).
    • Bridges PreToolUse / PostToolUse nudges (qa-reminder, specs-nudge, post-commit, check-task-completion) into .context/state/agy-pending-<sessionID>.txt via QueuePendingAgy and flushes them as {"injectSteps":[...]} on the next PostInvocation (heartbeat) or PreInvocation (check-context-size) via FlushAgySteps.
    • Extends ScanTranscriptForTokens to sum input_tokens + cache_read_tokens on PLANNER_RESPONSE lines when scanning Antigravity transcript.jsonl files.
  2. Embedded Antigravity Plugin Root & Skill Sync ([AGY2]):

    • Ships internal/assets/agy/ (plugin.json, hooks.json, mcp_config.json, rules/AGENTS.md, assets/logo.svg, and 50 skills/ctx-*/SKILL.md) embedded into the ctx binary.
    • Adds hack/sync-agy-skills.sh and make sync-agy-skills to mirror internal/assets/claude/skills/ and automatically split any SKILL.md body exceeding Antigravity's 24,000-byte limit (ctx-kb-ingest, ctx-architecture) into SKILL.md + references/details.md.
    • Validates cleanly under agy plugin validate internal/assets/agy --strict --json ("findings": []).
  3. Project-Local Setup Deployer (ctx setup agy [--write]) ([AGY3]):

    • Adds internal/agy/ (Detect, PluginEnabled, MergeHooks, MergeMCP, SyncSkills) and internal/cli/setup/core/agy/ (Deploy, Preview).
    • Deploys .agents/hooks.json, ~/.gemini/config/mcp_config.json, AGENTS.md, and .agents/skills/, and short-circuits project-local hook/skill deployment when the global ctx@local-plugins plugin is enabled in ~/.gemini/antigravity-cli/settings.json to prevent duplicate hook execution.
    • Registers agy in steering.SyncTool (ConsumesDirectly polite skip for AGENTS.md), .ctxrc JSON schema, and CLI documentation (docs/cli/setup.md, docs/operations/integrations.md).
  4. Session Transcript Parser (ctx journal import) ([AGY4]):

    • Adds internal/journal/parser/agy.go (Agy implementing Session) and registers ~/.gemini/antigravity-cli/brain in DefaultSessionDirs().
    • Parses transcript.jsonl (USER_INPUT and PLANNER_RESPONSE steps, stripping <USER_REQUEST>, <ADDITIONAL_METADATA>, and <SYSTEM_MESSAGE> wrappers, extracting thinking, tool calls, and token usage) while skipping transcript_full.jsonl duplicates.
    • Resolves session CWD via ~/.gemini/antigravity-cli/history.jsonl and documents Antigravity in docs/cli/journal.md.

Verification

  • agy plugin validate internal/assets/agy --strict --json -> "findings": [] (50 skills, 1 hook config, 1 MCP server, 1 rule)
  • go test ./internal/agy/... ./internal/cli/setup/core/agy/... ./internal/cli/system/... ./internal/assets ./internal/assets/read/skill/... ./internal/journal/parser/... ./internal/steering/... ./internal/entity/... ./internal/write/setup/... ./internal/compliance -run "TestShippedHooks|TestEveryDocPage|TestAgy"
  • go test ./internal/audit -run "TestNoMixedVisibility|TestNoMagicStrings|TestNoDeadExports|TestDescKeyYAMLLinkage|TestTypeFileConvention|TestDocComments"

…d pending queue

Implement [AGY1]: auto-detect Antigravity camelCase hook payloads in entity.HookInput, chdir to workspacePaths[0] and reset rc before state.Initialized(), emit Antigravity JSON protocol responses (injectSteps, decision allow/deny, {}), and bridge PreToolUse/PostToolUse nudges into .context/state/agy-pending-<sessionID>.txt for flushing on PostInvocation/PreInvocation.

Spec: specs/agy-integration.md
Signed-off-by: Ersan Bilik <ersanbilik@gmail.com>
Implement [AGY2]: ship embedded native Antigravity plugin at internal/assets/agy (plugin.json, hooks.json, mcp_config.json, rules/AGENTS.md, assets/logo.svg, and 50 ctx-* skills), add hack/sync-agy-skills.sh with 24,000-byte SKILL.md body splitting into references/details.md, and enforce hook/skill parity tests.

Spec: specs/agy-integration.md
Signed-off-by: Ersan Bilik <ersanbilik@gmail.com>
Implement [AGY3]: add ctx setup agy [--write] (alias antigravity) deploying .agents/hooks.json, ~/.gemini/config/mcp_config.json, AGENTS.md, and .agents/skills/ with global ctx@local-plugins short-circuit detection, register agy in steering.SyncTool (ConsumesDirectly), and document Antigravity setup and integration.

Spec: specs/agy-integration.md
Signed-off-by: Ersan Bilik <ersanbilik@gmail.com>
…anner

Implement [AGY4]: add Agy session parser in internal/journal/parser/agy.go reading ~/.gemini/antigravity-cli/brain/<id>/.system_generated/logs/transcript.jsonl and resolving session CWD via history.jsonl, and extend ScanTranscriptForTokens to sum input_tokens + cache_read_tokens on PLANNER_RESPONSE steps.

Spec: specs/agy-integration.md
Signed-off-by: Ersan Bilik <ersanbilik@gmail.com>
…g.json

When agy plugin disable ctx is executed, Antigravity records plugins.ctx.enabled=false in ~/.gemini/config/config.json while keeping plugins/ctx/plugin.json on disk. Check config.json in PluginEnabled so Detect() accurately transitions to StatePluginInstalledNotEnabled.

Spec: specs/agy-integration.md
Signed-off-by: Ersan Bilik <ersanbilik@gmail.com>
…sign findings

Check deferred file.Close() returns in hook tests, reuse claude.FieldInputTokens in session_token.go to avoid gosec G101 false positive, avoid err variable shadowing in agy_test.go and deploy_test.go, drop unused id assignment in parser/agy_test.go, and deduplicate pending nudges in DrainPendingAgy.

Spec: specs/agy-integration.md
Signed-off-by: Ersan Bilik <ersanbilik@gmail.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Support Google Antigravity (agy): native plugin, unified hook protocol, setup deployer, and transcript parser

1 participant