Skip to content
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ Get started in minutes:
## How It Works

1. **Security rules** are written in unified markdown format (`sources/` directory)
2. **Conversion tools** translate rules to IDE-specific formats (Cursor, Windsurf, Copilot, Claude Code)
2. **Conversion tools** translate rules to IDE-specific formats (Cursor, Windsurf, Copilot, Claude Code, Antigravity)
3. **Release automation** packages rules into downloadable ZIP files
4. **AI assistants** reference these rules when generating or reviewing code
5. **Secure code** is produced automatically without developer intervention
Expand Down
8 changes: 8 additions & 0 deletions docs/getting-started.md
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,11 @@ Before you begin, familiarize yourself with how rules work in your IDE:

:material-book-open-page-variant: [GitHub Copilot Instructions](https://docs.github.com/en/copilot/how-tos/configure-custom-instructions/add-repository-instructions)

=== "Antigravity"
Antigravity uses `.agent/rules` for rule configuration.

:material-book-open-page-variant: [Antigravity Instructions](https://codelabs.developers.google.com/getting-started-google-antigravity#8)

## Installation

### Option 1: Download Pre-built Rules (Recommended)
Expand Down Expand Up @@ -95,6 +100,7 @@ uv run python src/convert_to_ide_formats.py --source core owasp
cp -r dist/.cursor/ /path/to/your/project/
cp -r dist/.windsurf/ /path/to/your/project/
cp -r dist/.github/ /path/to/your/project/
cp -r dist/.agent/ /path/to/your/project/
```

## Verify Installation
Expand All @@ -103,6 +109,8 @@ After installation, your project structure should include:

```
your-project/
├── .agent/
│ └── rules/
├── .cursor/
│ └── rules/
├── .windsurf/
Expand Down
3 changes: 2 additions & 1 deletion src/convert_to_ide_formats.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
from collections import defaultdict

from converter import RuleConverter
from formats import CursorFormat, WindsurfFormat, CopilotFormat, ClaudeCodeFormat
from formats import CursorFormat, WindsurfFormat, CopilotFormat, ClaudeCodeFormat, AntigravityFormat
from utils import get_version_from_pyproject
from validate_versions import set_plugin_version, set_marketplace_version

Expand Down Expand Up @@ -128,6 +128,7 @@ def convert_rules(input_path: str, output_dir: str = "dist", include_claudecode:
CursorFormat(version),
WindsurfFormat(version),
CopilotFormat(version),
AntigravityFormat(version),
]

# Only include Claude Code for core rules (committed plugin)
Expand Down
2 changes: 2 additions & 0 deletions src/formats/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@
from formats.windsurf import WindsurfFormat
from formats.copilot import CopilotFormat
from formats.claudecode import ClaudeCodeFormat
from formats.antigravity import AntigravityFormat

__all__ = [
"BaseFormat",
Expand All @@ -38,4 +39,5 @@
"WindsurfFormat",
"CopilotFormat",
"ClaudeCodeFormat",
"AntigravityFormat",
]
74 changes: 74 additions & 0 deletions src/formats/antigravity.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,74 @@
# Copyright 2025 Cisco Systems, Inc. and its affiliates
#
# SPDX-License-Identifier: Apache-2.0

"""
Antigravity Format Implementation

Generates .md rule files for Antigravity with YAML frontmatter.
"""

from formats.base import BaseFormat, ProcessedRule


class AntigravityFormat(BaseFormat):
"""
Antigravity format implementation (.md rule files).

Antigravity uses .md files with YAML frontmatter containing:
- trigger: 'always_on' or 'glob' (activation type)
- globs: (if trigger is 'glob') File matching patterns
- description: Rule description
- version: Rule version

Rules use activation types (Always On or Glob) to determine when
they apply, similar to Windsurf's implementation.
See: https://antigravity.google/docs/rules-workflows
"""

def get_format_name(self) -> str:
"""Return Antigravity format identifier."""
return "antigravity"

def get_file_extension(self) -> str:
"""Return Antigravity format file extension."""
return ".md"

def get_output_subpath(self) -> str:
"""Return Antigravity output subdirectory."""
return ".agent/rules"

def generate(self, rule: ProcessedRule, globs: str) -> str:
"""
Generate Antigravity .md format with YAML frontmatter.

Args:
rule: The processed rule to format
globs: Glob patterns for file matching

Returns:
Formatted .md content with trigger, globs, description, and version

Note:
Antigravity rules use activation types:
- 'always_on': Rule applies to all files (when alwaysApply is true)
- 'glob': Rule applies to files matching glob patterns (language-specific)
"""
yaml_lines = []

# Use trigger: always_on for rules that should always apply
if rule.always_apply:
yaml_lines.append("trigger: always_on")
else:
yaml_lines.append("trigger: glob")
yaml_lines.append(f"globs: {globs}")

# Add description (required by Antigravity spec)
desc = self._format_yaml_field("description", rule.description)
if desc:
yaml_lines.append(desc)

# Add version
yaml_lines.append(f"version: {self.version}")

return self._build_yaml_frontmatter(yaml_lines, rule.content)
Loading